OK while I'm on a roll... how about this stuff? Shout if you object at
all to making changes based on these. I would only proceed with stuff
that seems unanimously acceptable.


One never needs to use this String constructor -- actually I am not
sure why it exists:
new String("foo")
All it does is make a String that != "foo" (though it .equals("foo"))


main() can just "throws Exception" -- while normally bad practice to
expose an API that throws so broad an exception signature, nobody
should invoke main() in a program.


We should use Java-style array syntax instead of C-style: String[] foo
instead of String foo[]. I always thought the latter was weird and not
sure why Java preserved it.


In JUnit, you can use
assertEquals(foo, bar);
rather than
assertTrue(foo.equals(bar))

The upside is it will automatically write an intelligent error message
that highlights the difference between expected and actual.


This:
public void foo() {
  super.foo();
}
doesn't do anything -- can just be removed since the overriding method
only delegates to the superclass anyway.


Also should the copyright statement always be the very very first
thing in the file? I had thought so.


Another point of syntax: always use { and } even when the body is one
line? I tend to favor it as it avoids this bug:
if (...)
  statement1;
  statement 2 added sometime later but is not actually in the if statement;
... and also because it naturally adds a nearly-blank line after the
body of the block


Where possible I think we should declare variables and arguments by
interface, like:
Map map = new HashMap();
instead of
HashMap map = new HashMap();

Reply via email to