Book review: Effective Java by Joshua Bloch
If you write Java as part of you job, you need to read this book. If you are learning Java, and hope to write Java as part of a future job, you need to read this book. So for many developers, the question of whether you should read this book is answered very quickly. The most important questions that remain are when to read Effective Java, and why to read Effective Java.
This is not a book to read to learn Java, Bloch assumes throughout that you have a familiarity with the language. It is also not a book to help you take the next steps after learning core Java, such as learning popular APIs such as JDBC, Java EE, or Swing. Effective Java is unlikely to equip you to accomplish any programmatic goal in Java that you were unable to code before reading it.
If you are overly pragmatic, it may seem that this book meets no real need. But if you have learned several languages, the purpose of this book, and the importance of books like this, is obvious.
Why read this book? To learn how Java ought to be written. Any programming task can be coded in a variety of ways, and Effective Java is about writing Java code that is understandable, maintainable, and fits with the design of the language. In other words, Effective Java will teach you how to work with Java, rather than working against it.
As for when to read this book, you should get this book as soon as can write code in Java. This is the book to get when you find yourself thinking, “I know a way to do it, but I’m wondering what is the right way.”
The book is structured with 78 “items” divided into ten sections, including “Classes and Interfaces”, “Generics”, “Enums and Annotations”, “Exceptions”, “and “Concurrency.” Each item takes a narrow topic and argues for a preferred practice. Some items in the “Classes and Interfaces” section are “Favor composition over inheritance”, “Design and document for inheritance or else prohibit it”, and “Prefer interfaces to abstract classes.” Each item is supported with concise arguments and brief examples, and often suggestions of possible exceptions to the rule. This is a very easy read, due to the short chapters and Bloch’s clear exposition. Each entry is like a blog post, easily digested in a short amount of time.
This book is a classic that will continue to fill an important need for as long as Java is relevant.