Book Review - Debug It!
December 13th, 2009 by Sam“Debug It!” (UK) is more than a book on debugging best practices - it’s a motivational tool that succeeds in making debugging sound like fun.
Full of humorous and insightful anecdotes, the main message is “nobody writes perfect code - this is how you deal with it”.
Paul Butcher does a great job of succinctly documenting the different types of bugs that show up in the wild, and best practices on how to find them and stop them appearing again. The book places a strong emphasis on development in a team environment, not neglecting the human factors that are often the trickier bits to manage.
For a good programmer, many of the best practices in “Debug It!” will not come as a surprise, the true value is in having all this experience documented in a single place - you’re not the only one who’s had to solve these problems. That said, even seasoned programmers will feel challenged at times by thought provoking advice such as Butcher’s recommendation that you occasionally work in Customer Support to get closer to your customers.
Despite having thoroughly enjoyed reading “Debug It!”, I cannot help but disagree with much of Section 10.1 “Assumptions and Assertions”. The book recommends that methods begin with assert statements to check validity of parameters, e.g.
assert name.length() > 0 : "name cannot be empty";
whereas I prefer explicit checks on method parameters, with appropriate exceptions being raised
// static imports from com.google.common.base.Preconditions
checkNotNull(name, "name");
checkArgument(!name.isEmpty(), "name cannot be empty");
which will result in a NullPointerException or an IllegalArgumentException, respectively, if name is faulty. Most importantly, these checks are not dependent upon assertions being enabled at runtime. In my opinion, assert is best used deep within internal code, not in public APIs (even if public between internal projects) nor to validate user input.
The final chapter “Anti-Patterns” is perhaps the most insightful. If you are too busy to read this delightful book in its entirety, then at least read the final chapter whilst mandating that your entire development team read “Debug It!” from cover to cover. Report bugs on the errata.
Debug It! Review Roundup | Paul Butcher wrote:
December 18th, 2009 at 11:28 pm