My prefs are like Adams (2 char indents, no tabs) except I don't like using up a line for opening braces (this lets me see more code on my screen at once). I do use up a line for the closing brace, though.

I agree with Thilo on things like running findbugs, etc. as a general practice, and fixing the problems it finds.

What's the benefit of prefixing member refs with "this"? I find it makes the code harder to read. Eclipse can be set up to "color" member refs, in any case.

Re posting things:  you can post to the web-site.

You can also post to your twgoetz website - remember Ken Coar said we all had one.
-Marshall

Thilo Goetz wrote:
Adam Lally wrote:
I noticed Thilo checked in a file (SofaTest) that showed as having
many changes in it, mostly I think due to having been reformatted in
Eclipse with Source -> Format.  This makes it hard to see what
actually changed.

Yes, that file had tabs which made it unreadable. On the other hand, if you use Eclipse, it is not at all hard to see what changed as the structural compare will show you only logical differences.


What should we do about this?  Could we agree on a common code style,
and maybe even post an Eclipse code style preference file on the
website, so that at least developers who use Eclipse can share it?

+1. The Eclipse built-in Sun Java coding style is not too bad, but it does use an indent of 4, which I find excessive.


I know that some of our code is inconsistently formatted currently,
since different developers have used different conventions, sometimes
even within the same source file.  So the codebase would probably
benefit from being completely run through the Eclipse reformatter.

Of course we'd have to agree on the style to use.  Personally I like
two space indents, a complete ban on the use of tabs, and each open
brace on a line by itself.

We could start here: http://java.sun.com/docs/codeconv/html/CodeConventions.doc.html

I don't like open braces on a line by themselves, but it's not something I would fight for.

Actually, the formatting is not high on my list of priorities. If there are tabs in a source file, or 200 character lines, I just do a Ctrl-Shift-f and it's something I can read. Given the compare support in Eclipse, I don't worry about that. If somebody else reformats my files, that's fine with me (it happens all the time).

I'm personally much more worried about stylistic questions that are not mere formatting. I have my compiler warnings on pretty sensitive settings, and I hate it when a source file has dozens of warnings because it makes it very hard to see real issues. For example, prefixing the use of member variables with "this" is an absolute must. Another thing is the use of something like findbugs. For example, the test case I fixed opened half a dozen streams (on the same file) without closing a single one (with the effect that I couldn't just delete the file at the end of the test case). Findbugs will find that kind of issue (and has on my code, many times).

So if we're thinking about coding conventions, is that something I we can consider as well? I realize that we may not get agreement on everything, but we could see how far we can get. Michael and I have actually gone through this excercise before and have put together a document that describes our preferred compiler settings, including a rule set for findbugs. I'd post it, but I don't know where.

--Thilo




Reply via email to