[josm-dev] Source code formatting template?
Frederik Ramm
frederik at remote.org
Wed Aug 27 10:02:49 BST 2008
Hi,
> 1. Indentation: space vs. tab
I'd go for spaces always.
> 2. Maximum line length:
> A large number of files do contain very lengthy lines, mostly for
> defining strings with display messages. Other files use a maximum line
> length of ap. 100-140 characters (which is my favorite setting, too).
> Files with a max. line length of 80 characters are very rare.
Generally I'd avoid long lines but we must take care not to make life
difficult for translators. Does it pose a problem for translation if
one says
tr("some " + "long " + "message")
instead of
tr("some long message")
or is that un-problematic? I am not familiar with the translation
mechanism and don't know whether it has a full parser or relies on
everything being one string. Dirk probably knows?
> 1. JavaDoc sections: the formatter compacts this sections and removes
> line breaks and alignment spaces which is unfamiliar at a first glance,
> but IMHO it is not bad as it shows how the JavaDoc comment will look
> like in the generated HTML-JavaDoc.
It is more important for us to have good and readable comments in the
code than generated HTML Javadoc. Nobody (as far as I am aware) uses
Javadoc with JOSM. Of course it would be good to have all, but faced
with a choice I'd opt for good and readable comments instead of good and
readable Javadoc ;-)
If possible I would say the comments should not be touched by auto
formatting.
> 2. Spaces before and after operations: = < > + - * /
We normally have them. We also have spaces before ( and after ) but not
after ( and before ) but sometimes, in a complex expression, you'll
perhaps even want those extra spaces...
Bye
Frederik
More information about the josm-dev
mailing list