Indenting code?

Brad Wetmore bradford.wetmore at oracle.com
Thu Sep 13 17:21:25 PDT 2012


Netbean's automatic formatting does a pretty good job with new code. 
However, I think the general advice is to not change existing code just 
because.  When you're dealing with multiple release families, it makes 
the merges much more difficult.

Brad



On 9/13/2012 6:18 AM, John Zavgren wrote:
> Greetings:
>
> I have a simple question about how to enforce code styles for: java, c, and c++. I know there are style guides that legislate the indentation, "curly brace and parenthesis management", etc.
>
> I'm looking for a simple automatic way to transform any source code file so that it's image is guaranteed to be "correct". No thinking required.
>
> What I normally do is use an open source tool named "indent", e.g.,
>
> indent -bap -bbb -bl -nce -l80 file1.cpp file2.h file3.c file4.java
>
> And, I put an "indent" target in my make files.
>
> Consequently whenever I make something, the very first step is to format the code, and I know that when I do a check in later on... I never have to think about whether or not the code conforms to a style guide... because the options I gave to "indent" implemented this guide. (You can do similar things with emacs too.)
>
>
> Any ideas?
>
> Thanks!
> John Zavgren
> john.zavgren at oracle.com
>



More information about the net-dev mailing list