W3C home > Mailing lists > Public > public-mobileok-checker@w3.org > July 2007

Java style notes

From: Sean Owen <srowen@google.com>
Date: Sun, 1 Jul 2007 12:59:37 -0400
Message-ID: <e920a71c0707010959r42812bb6uf114d3d479686b4a@mail.gmail.com>
To: public-mobileok-checker <public-mobileok-checker@w3.org>

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
- 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

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:21:18 UTC