[Book review] Effective Java

Alberto de Blas
2 min readApr 22, 2021

If you are familiar with Java but you want to improve and get another step up this is your book. The book presents heuristics about software design concepts and some OOP principles. It is structured in 90 items grouped in 12 chapters. Each chapter covers a must know Java feature.

Each item is reasoned with examples and also there is space to reflect and warn about the cases that do not apply and the caveats and tradeoffs of each technique. The code examples shown are very useful to understand better the concepts explained, maybe now that we are quite used to digital book editions, could be improved by highlighting the code.

This book is a must for every Java programmer!

To finish, the key items and concepts that I take with me from this book are:

  • Enforce the singleton property with an enum type
  • Always override hashcode when overriding equals
  • Minimize the accessibility of classes and members
  • Minimize mutability (and all the reflections about immutability spread across all the items)
  • Design for inheritance or prohibit it
  • Use bounded cards to increase API flexibility
  • Use enums instead of int constants
  • Return empty arrays for collections, not nulls
  • Prefer side-effect free functions in streams
  • Beware the performance of string concatenation
  • Include failure-capture information in detail messages
  • Prefer executors, tasks, and streams to threads

--

--