(by Joshua Bloch, (publisher info))
Consider providing static factory methods instead of constructors
Enforce the singleton property with a private constructor
Enforce noninstantiability with a private constructor
Avoid creating duplicate objects
Eliminate obsolete object references
Avoid finalizers
Obey the general contract when overriding equals()
Always override hashCode()
when you override equals()
Always override toString()
Override clone()
judiciously
Consider implementing Comparable
Minimize the accessibility of classes & members
Favor immutability
Favor composition over inheritance
Design and document for inheritance or else prohibit it
Prefer interfaces to abstract classes
use interfaces only to define types
Favor static member classes over nonstatic
Replace structures with classes
Replace unions with class hierarchies
Replace enums with classes
Replace function pointers with classes and interfaces
Check parameters for validity
Make defensive copies when needed
Design method signatures carefully
Use overloading judiciously
Return 0-length arrays, not nulls
Write doc comments for all exposed API elements
Minimize the scope of local variables
Know and use the libraries
Avoid float and double if exact answers are required
Avoid strings where other types are more appropriate
Beware the performance of string concatenation
Refer to objects by their interfaces
Prefer interfaces to Reflection
Use native methods judiciously
Optimize judiciously
Adhere to generally accepted naming conventions
Use exceptions only for exceptional conditions
Use checked exceptions for recoverable conditions and runtime exceptions for programming errors
Avoid unnecessary use of checked exceptions
Favor the use of standard exceptions
Throw exceptions appropriate to the abstraction
Document all exceptions thrown by each method
Include failure-capture information in detail messages
Strive for failable atomicity
Don't ignore exceptions
Sync access to shared mutable data
Avoid excessive synchronization
Never invoke wait outside a loop
Don't depend on the thread scheduler
Document thread safety
Avoid ThreadGroups
Implement Serializable judiciously
Consider using a customized Serializable form
Write readObject()
methods defensively
Provide a readResolve()
method when necessary
Last modified 07 October 2024