Book Review Department Editor Warren Keuffel
Save Time While Debugging
Art Sedighi
Java Puzzlers: Traps, Pitfalls, and Corner Cases by Joshua Bloch and Neal Gafter, Addison-Wesley, 2005, ISBN 0-321-33678-X, 304 pages, US$39.99.
Traps, pitfalls, and corner cases—every programming language has them. In Java Puzzlers, Joshua Bloch and Neal Gafter document Java’s trouble spots, including silent integer overflows, object-construction order, floating-point arithmetic, inner class complexities, and method and constructor overloading.
The authors present each case as a puzzle. By the time you’re halfway through the book, you realize that the title should be You Thought You Knew Java, but You Don’t. As soon as you begin to understand a topic, the authors throw you a curve ball, and you’re back where you started. Fortunately, the authors keep the puzzles short and focused. Each puzzle covers just one case, explained in detail before moving on. So, you can just pick up the book for 10 minutes and read a couple of chapters easily.
The book’s major sections cover
- expressive puzzles (particularities of expression evaluation),
- character puzzles (the difficulties of dealing with strings and characters),
- loopy puzzles (situations that will make your loop-to-loop run forever),
- exceptional puzzles (exception-handling difficulties),
- class-related puzzles (class instantiations),
- class design puzzles (class design pointers), and
- library-related puzzles (Java class libraries’ initialization, hashmaps, sorting, and so forth).
Java Puzzlers ends with a summary chapter that’s a good quick reference. The source code to all the examples is available online. I recommend this book to any Java developer because knowing the language’s pitfalls could save a lot of time when debugging occurs.
Art Sedighi is a senior consulting engineer at DataSynapse and a freelance writer. Contact him at sediga@alum.rpi.edu.