Growing Object-Oriented Software, Guided by Tests

Steve Freeman, Nat Pryce (2009)
Review date: July, 2011
Summary

This book comes in five parts. The boundary between the first two isn't all that clear. Parts one and two form a good introduction and theory section, where the authors discuss many principles and design issues in a pleasing to read manner. We get some OO principles, JUnit, test-driven development and a combination thereof. The chapters in these sections also lay the foundation to the general development approach advocated and followed in the book. All of this in only 70 pages.

Part three is a long example, spanning roughly 150 pages and eleven chapters. The example consists of an auction sniper application that talks XMPP.

Part four has five chapters that dig deeper into some technicalities and questions that arise during unit testing. It contains advice about how to create good expectations and assertions, how to write tests with high readability, and how to create complex test data.

Finally, part five has three chapters on testing persistence, threads, and asynchronous code, which are important topics that didn't fit elsewhere.

Opinion

I'm writing this review a while after reading the book, so I might not remember all the details. Basically, I remember the book as being centered around the 150 page example. That's a strength and weakness. The strength is that the example is actually about something quite realistic and gets worked through, while the weakness is that the rest of the book fades into the background; the example takes over.

For instance, in the first section, the authors share lots of wisdom in very few pages. I'd say that the introductory chapters form one of the best texts on test-driven, object-oriented design I've read so far. There are many good pointers here (the one I found particularly useful was to use unit tests to verify behavior, not to test methods, a fault I myself have been guilty of for quite a couple of years), but I sort of forgot about these pages halfway through the example.

It may not be apparent from this review so far, but basically the book is about writing software using test-driven development that puts emphasis on end-to-end tests, and while unit tests are still important, I get the feeling that they are treated as something secondary. This is pointed out by Kent Beck in the foreword and phrased like: "the authors don't do the same kind of TDD that I do" (or something like that). And that's another strength!

I may be wrong here, but the classic TDD described in Test-driven Development by Example is quite hard to translate to your average n-tier, EJB/Spring/Struts/Oracle application. At least it was for me. Here we finally have a book that tries to bring TDD to the masses!

While on the test subject... I'm so happy that the authors didn't fall to the temptation and employed an acceptance test framework. Instead, they show that you can do end-to-end without a wiki or HTML-pages with extra annotations. That's very important in my opinion. Throughout the book, the auction sniper application is tested using JUnit and the WindowLicker framework. This is a bonus, since texts on testing Swing applications aren't that common.

Then there are the chapters after the example. By the time I got that far, I felt kind of: "Ok, I'm done. Next book", which was a pity, since these chapters answer many questions that you start asking once you pass the beginner level in unit testing. I've wrestled with every single question treated here: what do good expectations look like? How do we write good assertions? Do we need to mock values? Surely ten more such questions are answered here. Unfortunately I was kind of exhausted by the example, so I just skimmed through this section.

Lastly, the final three chapters They are well-written, treat hard and interesting topics, but feel sort of out of place. They are very interesting, but they make the contents a bit incoherent and shift the focus of the book slightly. They are simply not needed, in my opinion. I would almost like this book to be split into two, one companion example, and one main body, where the last three chapters would be better integrated.

Verdict, at last! This is a good book. It's modern, not overly theoretical, and covers many topics that other books miss or shy away from. It teaches you another testing framework, and has lots of examples of JUnit's assertThat method, which means that it will teach you a thing or two about tools.

Personally, I found the big example a bit tedious after a while, but that's a personal preference. The example is realistic, is not a web application (which is rare these days), and serves well in teaching the concepts and techniques from the book.

Buy and read! It's the best book on test-driven development you'll get right now.

Who should read this book

This is one of the best texts on test-driven development out there right now. Those who want to learn TDD in a modern way, guided by a realistic example, better pick this one up. Even if you think you know your stuff, you might get some ideas from this book.




News

  • 2015-09-29

    It's been almost one and a half year since I reviwed a book! I've been too absorbed by Writing my own. Anyway, I'm back with Jeff Patton's relatively...
  • 2014-01-04

    New category! Performance! Reviewed The Every Computer Performance Book. Check it out!
  • 2013-09-10

    Reviewed a book that' slightly less technical, but much more fun to read. It's I.T. Confidential.
  • 2013-08-13

    Reviewed yet another book on Visual Studio 2012 and TFS. I also created a "Microsoft" category and moved the other TFS book there from the "Tools"...
  • 2013-08-05

    Updated the FAQ. Included information about getting a book reviewed.