Summary of Effective Java 3rd Edition by Joshua Bloch

Pravinkumar Singh
7 min readJun 9, 2023

“Effective Java” is a well-known book by Joshua Bloch, which covers best practices, patterns, and idioms for writing high-quality Java code. The third edition of the book contains 90 items organised into 11 chapters. I have tried to summarise each item, chapter-wise:

Creating and Destroying Objects

  1. Consider static factory methods instead of constructors: Static factory methods offer benefits over public constructors, such as meaningful names, easy caching, and control over object creation.
  2. Consider a builder when faced with many constructor parameters: Builders provide a more readable and flexible way to construct objects with multiple parameters.
  3. Enforce the singleton property with a private constructor or an enum type: Ensure that only one instance exists by using a private constructor or an enum type singleton.
  4. Enforce non instantiability with a private constructor: Prevent object instantiation in utility classes by using a private constructor.
  5. Prefer dependency injection to hardwiring resources: Configure objects with dependencies rather than creating them directly, improving modularity and testability.
  6. Avoid creating unnecessary objects: Use existing objects or immutables…

--

--

No responses yet