[josm-dev] Developement Guidelines - Style guide

Dirk Stöcker openstreetmap at dstoecker.de
Sun May 5 12:04:03 UTC 2013

On Sun, 5 May 2013, Tobias Hirning wrote:

> Is there any style guide for coding?

It's in the wiki:

  * make sure there is no trailing white space
  * don't use multiple consecutive empty lines
  * JOSM uses 4 characters indentation and no tab stops
  * Document your code thoroughly. Many people will thank you :)

Obvious things aren't mentioned here like proper variable and function 
names, using spaces to separate elements, Use return to split long lines, 

> The wiki page
> https://josm.openstreetmap.de/wiki/DevelopersGuide/StyleGuide
> only refers to the Oracle Javadoc style guide and not to the Oracle Code
> Conventions for Java.
> The reason why I am asking is, that I came along a big number of case where
> for if-, else-, if-else- and for-blocks don't use braces which makes the code
> sometimes hard to read and sometimes hard to maintain.

Follow the style of the existing files except it violates the few rules we 
have. But when you do changes, please no reformating of untouched code parts.

Regarding brackets. Single line statements don't need brackets in my eyes. 
They only clutter the code. Thought there are exceptions (e.g. if there is 
an else after a single line if). Use your brain and no rules :-)

http://www.dstoecker.eu/ (PGP key available)

More information about the josm-dev mailing list