...
Never assume that the user of your code is smart enough to use it correctly. Anticipate abusive patterns and structure your code so that it is hard and next to impossible to go the wrong way. Code that is not meant to be extended should be final by default. Reduce the visibility of your methods to the minimum, as every protected or public method is a technical dept, as the method and its semantics must be maintained for the lifetime of the library or application.
- Never swallow exceptions.
Exceptions from the client code must be handled gracefully or must be (possibly wrapped up and) re-thrown. A caught exception should never cause your code to fail with a null-pointer-exception and generally should not cause your code to return null (unless this is the documented semantics, which it rarely is).
- Never use System.out or Throwable.printStackTrace(..)
Use commons-logging instead. There is no sane reason for polluting the standard output streams.
- Follow the secure coding guidelines