Implement the Cloneable interface if an object might need to be
cloned, and implement from scratch rather than picking up the default
behavior from Object .
If you override Object.equals , also override Object.hashCodes , and
Use final only for the declaration of constants. -OR-
Use final only where the superclass defines the interface of all of the
methods (disregarding implementation-specific methods).
Guidelines for packaging and file structure
A .java file should contain a single class, and be named the same as the
class, including the correct use of case.
Place even private classes in separate files.
Place interfaces in separate files.
A package should contain a logical grouping of classes.
Place files in a structure that mirrors package structure.
Guidelines for leaks and performance
Pair code that handles allocation and freeing of resources as closely
together as possible, preferably in the same method.
With collections, add s should not be added to the code without associ-
ated remove s. The primary exception is collections that use weak or soft
EJB s should be accessed through a common command layer or facade.
Keep redundant computations outside of loops and loop tests.
Guidelines for testing
Code unit tests first.
Include a main for unit tests.
Organize test cases. Pick a default organization and stay with it.
Append built-in tests with the word test .