Java style notes

Good afternoon -- more Java style notes. I assure you the consistency
is worth it. "cvs update" and see more of my handiwork.


- Use imports -- don't say "java.util.LinkedList" everywhere; import
it and say "LinkedList"
- Don't use wildcard imports like "import java.util.*" Seems odd maybe
but I rarely see wildcard imports in new Java code. Most people,
including me, prefer explicitly enumerating dependencies.
- Wrap at 120 columns, not 80. 80 is just too small to harm
readability. 120 is a reasonable compromise.
- "if (foo == true)" is redundant; use "if (foo)"
- Always use braces for all blocks introduced by if, while, do, etc.
conditionals, even if they're one line
- We need the W3C copyright statement on every file:
  // (c) COPYRIGHT MIT, INRIA and Keio, 2007 and onwards.
  // Please first read the full copyright statement in file COPYRIGHT.html
- "public" is redundant when declaring interface methods
- Nothing except a class name begins with a capital letter, by
convention, in Java
- Default access level to private or package-private; nothing should
be public by default
- printStackTrace() is never the right thing to call. Usually you want
to re-throw an exception. Logging is more appropriate than
stdout/stderr
- On the same note, System.out/System.err should never be used except
maybe in a main() method


I like CSSResource + EmbeddedCSSResource. The latter captures an
inline style element right?

Received on Sunday, 1 July 2007 16:59:47 UTC