"Test-Driven Development - A Practical Guide" by David Astels and "Test-Driven Development By Example" by Kent Beck

June 14, 2006

Both books discuss test-driven development, both are succinct in style, but David Astels's journey into TDD covers a broader set of additional topics such as refactoring, JUnit, JUnit extensions, JUnit tools, XP, and even Agile Modelling. In some ways it's hard to talk about TDD without any knowledge of JUnit or mock objects but leaving that aside Kent Beck's book makes for a better and more focused introduction to the principles of TDD.

David Astels has collaborated with various practitioners on a number of sections in his book. The chapter on JUnit has contributions from the maintainers of the various JUnit extensions such as Tim Bacon of Thoughtworks on xmlUnit, Mike Clark of Clarkware on JUnitPerf, Jens Pipka on the Daedalos JUnit extensions, and Mike Bowler on the Gargoyle Software Extensions. The appendix on Agile Modeling was contributed by Scott Ambler and the book's forward was written by Ron Jeffries - a well-recognized name in XP land.

Indeed in going through David Astels' book one feels the author's deliberate attempt at compiling a broad summary of topics relavent to TDD. This includes separate chapters on refactoring, JUnit and its philosophy, programming by intention, as well as a lengthy 100 page appendix on extreme programming. Perhaps even more valuable from a practitioner's point of view are the chapters on JUnit extensions, JUnit-related tools (Jester, NoUnit, Clover), and Mock Objects (covering MockObjects and EasyMock).

Where the two books really stand apart is in how TDD is presented. Kent Beck starts out with a brief and compelling introduction of how early one Friday, his boss came to introduce a new prospective customer for their bond portfolio management system. This goes on to set up the "Money Example", which is gradually developed in the first half of the book by following the TDD mantra - write a test, follow up with code, and refactor to remove duplication. In his book David Astels also traces the development of a real example - the "Movie List" example but it takes an entire 200 (albeit worthwhile) pages to get there.

Kent Beck remains relentlessly true to the TDD approach. Reading his book really feels like you're sitting next to him with a camera and a microphone recording the experience. We hear what goes on through his mind, we see what decisions he makes and we learn what principles he adheres to for making those decisions. Unlike other books where you expect experiences to be summarized, here Kent Beck has done the opposite - he has left you to go through the unaltered experience of test-driven development. For this reason I highly recommend to follow the book by typing and compiling the code in the computer.

The second part of Kent Beck's book contains various TDD patterns summarizing the prinicples presented in the first half. This includes some of the well-known Go4 design patterns but layed out with a bigger focus on refactoring - something Kent Beck believes is conspicously missing from the original gang-of-four design patterns book.

In summary both of these books are worth the read but for different reasons. David Astels book as its title suggests is more concerned with giving you a broader preparation for practicing TDD covering a range of topics related to XP. Kent Beck's book on the other hand leaves you to learn about those other topics separately but does a much better job at conveying the principles of test-driven development by giving you a great example to follow and complementing it with a section on TDD and design patterns.