Skip to content

Instantly share code, notes, and snippets.

@HarshadRanganathan
Last active August 3, 2019 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HarshadRanganathan/6ef00c1f95e8225cdc9f68671b0b9a29 to your computer and use it in GitHub Desktop.
Save HarshadRanganathan/6ef00c1f95e8225cdc9f68671b0b9a29 to your computer and use it in GitHub Desktop.
Chapter: Creating and Destroying Objects
[1] Consider static factory methods instead of constructors
[2] Consider a builder when faced with many constructor parameters
[3] Enforce the singleton property with a private constructor or an enum type
[4] Enforce non-instantiability with a private constructor
[5] Prefer dependency injection to hardwiring resources
[6] Avoid creating unnecessary objects
[7] Eliminate obsolete object references
[8] Avoid finalizers and cleaners
[9] Prefer try-with-resources to try-finally
Chapter: Methods Common to All Objects
[1] Obey the general contract when overriding equals
[2] Always override hashCode when you override equals
[3] Always override toString
[4] Override clone judiciuosly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment