[kepler-dev] Kepler Code Formatting

Aaron Schultz aschultz at nceas.ucsb.edu
Wed Dec 10 11:38:44 PST 2008


Hi Chad,

I also learned in CS101 that companies would impose style rules on 
employees and you just had to deal with it because somehow having the 
uniform codebase improved the overall productivity of the group.  I 
think the prof said something about individuals were better at adapting 
to a new formatting style than a whole groups was at adapting to an 
individuals style or something to that effect, can't quite remember (was 
a long time ago).

Currently there is a mixture of tabs and spaces used to indent code.  
Using tabs to indent code actually increases the individual's ability to 
customize the look of the code since every editor (that I've seen 
anyway) has an option to set the tab spacing (tab = 3 spaces, or tab = 4 
spaces, or whatever you prefer).  Tabs also make the size of the code 
smaller by using only one character for all of that indentation.  If you 
use spaces to indent then everyone is subjected to whatever indentation 
that you use.

As for where curly braces go and all that other stuff I don't really 
have an opinion on that except that the java editor in eclipse handles 
that very well.  Using "source->format" and "source->organize imports" 
Eclipse options is very easy to do and is very robust.

I really like the idea of periodically going through and running a 
standard formatting tool on core code and perhaps the standard modules.  
This way the developer can use whatever format they want while 
developing their code and so the only thing they need to deal with is 
that at some point in the future (probably long after they're working on 
it) it will get converted to the standard format.

I'd vote that we just use the default Eclipse settings for formatting to 
make things as simple as possible for everyone.  I've done some polling 
and it seems that the majority of folks are using Eclipse on a 
day-to-day basis for their code editing and formatting anyway and really 
could care less about the formatting.  I'd be happy to volunteer to 
reformat and clean imports on the Kepler code as soon as the new build 
is working well with Eclipse.

Aaron



Chad Berkley wrote:
>>
>> 11) Now might be a good time to fix up the indentation of the files
>> by running a tool like the Eclipse indenter.  The files are pretty hard
>> to read.  modules/util/src/org/kepler/gui/TabbedLibraryPane.java is an
>> example.
>
> My style or yours :)  I think we've had this discussion a few times. 
> While I'm all for having a uniformly styled code base, I also hate 
> working with other peoples' styles.  I know that I learned in CS101 
> that I need to just deal with it or talk to a psychologist about it or 
> something, but I still feel like it hampers my productivity when I 
> have to use a style that doesn't jive with the way I write code.  The 
> rule that we've had for a long time is that the file should be styled 
> in the author's format and that it should stay that way.  If there is 
> a file that is not formatted at all, or does not follow any style 
> guidelines (i.e. lines of the same block are not indented to the same 
> tab point, etc) then I have no problem reformatting them.


More information about the Kepler-dev mailing list