java-gnome 4.1.3, released 4 May 2013
Overview, News
Tutorials, API, and Hacking
Binaries and Source
Mailing Lists, IRC, and Reporting Bugs


Style guide: Source Code

Code Formatting

The code formatting tools available in modern IDEs are nothing short of miraculous.

Eclipse in particular has an outstanding code formatter that is highly configurable. This encourages people to tinker and have their code be just the way they like it. That’s a Good Thing (tm), but it plays havoc when it comes time to create diffs as patches to commit to the version control system. So we need to share a code format convention.

Java conventions, mostly

We ended up adopting what Eclipse termed the “Java conventions [builtin]”, with four modifications. Notably, this default Java style is set to convert tabs to 4 spaces. I personally prefer \t characters, but it makes a mess when looking at diffs or raw files because the terminal expands tabs to 8. So I’ll buy this one — better that your code looks correct at all times.

The modifications are:

Your patches have a much better chance of being accepted if they produce clean diffs, and that’s more likely to happen if you stick to these rules. If you’re using Eclipse, you will find “The java-gnome Style” pre-configured in the .settings/ directory. Just hitting Format should do the trick.

(Come on Sun boys and girls! Make me believe that NetBeans is better…)

Coding standards

TODO: coding practises. Not really too much to talk about here.


Originally written by Andrew Cowie 27 Nov 06. Last modified 9 Dec 06.

Contents copyright © 2006-2011 Operational Dynamics Consulting Pty Ltd, and Others. See AUTHORS file and source code history for the various files comprising this site for full details. This page was generated from a text document! We use John Gruber's Markdown syntax as ported to PHP by Michel Fortin. See MARKUP for details