We've all been bitten by different "new and improved" marketing schemes. Scanning store isles, you can see the "new and improved" moniker applied to everything from new marshmallow shapes with the same old flavor to a smaller package size at a higher price. Similarly, I sometimes feel wary of second edition books. The second edition often seems just to fix problems that should have been caught in the first.
None of this applies to Effective Java, second edition. Even if you've read the first edition, this second one deserves to be in every Java programmer's library.
I read the first edition soon after it came out in 2001. Since then I've kept up on the new Java releases, so I figured I didn't need the second edition. I figured wrong. The new addition has grown from 252 pages to 346 pages. It includes 23 new items and includes wonderful chapters on generics, enums, and the concurrency library—all of which were released in Java 5. The revised book expanded my horizons and capabilities in all these area.
For those who haven't read the first edition, Effective Java is not a Java primer, nor a Java reference. Instead, it consists of a set of items, each of which teaches a specific lesson about how to improve a Java program or design. Author Joshua Bloch follows the pattern used by Scott Meyers in Effective C++. The items are concise and simply named. For example, the Creating and Destroying Objects chapter includes "Eliminate obsolete object references" and "Avoid finalizers," among others; while the Concurrency chapter includes eight items—for example, "Synchronize access to shared mutable data." The format is very effective (pun intended).
Reading Effective Java is like looking over an expert's shoulder who's pointing out issues, traps, and pitfalls. Often I would think to myself, "That could never happen," and then the next paragraph would show how that exact problem came up in the Java libraries or in their usage. I found that whenever the author put something in bold, I wanted to sit up and pay attention. Bloch shares his wealth of experience so that we can all benefit.
The items are extensively cross-referenced. I was impressed when a code sample on page 74 included the comment: "See page 43 to find out why we use compare instead of = =." The book has a useful index and a good table of contents. It can serve as a good reference long after your first reading.
I tried hard to find problems with the book, because that is my job as a reviewer. While reading, I write down all the issues I find. For this book I wrote down a total of three minor issues. Three! I list them only for completeness: one missing cross reference that would have helped me, an example that needed a few more introductory comments, and an advantage of immutable objects that I would have liked to see mentioned earlier. There's nothing in those issues that would cause me to reconsider my strong recommendation:
On your next trip to the store, pass by the new marshmallow shapes and pick up the second edition of Effective Java. Then read it, keep it handy, and put it into practice in your work. Every Java programmer should have this new and improved edition.
John R. Dance is a principal architect at UIEvolution. You can contact him at firstname.lastname@example.org.