Dain Sundstrom kirjoitti:
On Oct 29, 2008, at 10:44 AM, Alex Grönholm wrote:

Formatter:
- max line width is 100 characters

I prefer 120, but as long as it is only suggestion it isn't a big deal for me.

I don't how you do your editing, but in my case, 120 characters is already so wide that I frequently have to shift my eyes horizontally to read the whole line, and it doesn't fit on my editor window (with 1600x1200 screen size). I expect many other developers to have even smaller screens, so I figured 100 characters would be a reasonable suggestion.
But like you said, it's just a recommendation.
- indentation is 4 spaces

Would XML be 4 spaces also?  I don't care if it is 2 or 4.

I meant 4 spaces for Java source files. For XML it could be either, I don't really care.
- javadocs are formatted

What does that mean?

Cleanup:
- always use braces with control statements (I actually disagree with this, and it's not even consistently used in existing code)

One line if statement should be allowed.  For example,

if (debug) System.out.println("This is a one liner");

I strongly recommend that the actual statement be put on a second line with an extra unit of indentation, like:
if (debug)
   System.out.println("This is a one liner");

for readability. Makes it really clear it's a control statement there.
- removes unused imports and local variables

Order and grouping of import should be specified. I use the following:

java.*
javax.*
<blank line>
others

I like this because it puts the important imports closest to the code.

Works for me. I didn't think it was important so I didn't initially include that.
- removes "this" qualifier for non-static method/field accesses (where possible)
- adds missing @Override/@Deprecated annotations

I don't like the @Override annotation in most cases. The only place I have used it is when doing complex subclassing of the SFSB container in geronimo, where it helps catch interface changes. In openejb we typically don't do complex subclassing since it is so brittle, so the @Override annotation just becomes annoying.
At least Eclipse inserts @Override automatically when you use the "Override/implement superclass methods" function from the Source menu. Even if you manually override something, two mouse clicks will insert the annotation. If all else fails, you could just use the cleanup function. I would guess IDEA has similar functionality to this, but I don't have it.


- removes unnecessary casts
- removes trailing whitespace
- corrects indentation

Code templates:
- for newly create .java files, inserts the ASL comment to the top

Also, in general, I dislike aligned text because it becomes a burden to maintain over time. There are places where it is nice (specifically simple look tables), but I find it annoying in javadoc comments and parameter declarations.

I don't think I suggested that anywhere, or maybe I misunderstand you. Could you please elaborate?



Reply via email to