Book Review: “The Grumpy Programmer’s Guide To Building Testable Applications”

« »

When most developers think about books on testing, they think about books that highlight things like “test driven development” or “how to build a test for X.” There are lots and lots of testing books out there that supposedly teach us how to write tests and reach milestones like “100% test coverage.” But at the risk of sounding risque, testing is very similar to sex: more people claim to do it than actually do, most people claim more experience with it than they actually have, and more people have advice on the subject than probably should.

This is not true of Chris Hartjes’ book, “The Grumpy Programmer’s Guide To Building Testable PHP Applications”. When I asked Chris if I could review his book, I expected a step-by-step guide to writing tests. What I got was a step-by-step guide to building an application that COULD be tested. There’s a big difference, and it’s important to understand the distinction.

Writing tests is certainly hard; Chris makes no bones about this. But testing is made unnecessarily difficult by bonehead developers who consistently write applications that are resistant or impossible to test. It is in this framework, then, that Chris focuses most of his energies: writing (or rewriting) an application to be testable. Rather than embracing a particular methodology, framework or behavior, Chris adopts the tactics and techniques that work to build applications that can be tested, and shows exactly how to test them along the way.

Chris’ book isn’t perfect by any stretch and it won’t solve every one of your test or application development problems. That’s not it’s purpose. It’s purpose is to provide examples and guidelines for building an application that won’t cause you to rip your hair out when you go to test it. Chris walks a fine line, but his experience with testing and application development gives him the credibility necessary to advise and instruct in this area.

There are many words of wisdom in the book, from “if it’s not yours, wrap it up” (on building wrapping layers) to “testing is good; testable applications are better.” His admonition that the development environment and the deployment environment should be as similar as possible helps eliminate those “it worked on my machine!” moments, and is something I’ve believed in for years.

The book is for sale at LeanPub for a suggested price of $15. In truth, it’s worth twice it’s price, and I highly recommend it to anyone who struggles with developing testable applications.

Brandon Savage is the author of Mastering Object Oriented PHP and Practical Design Patterns in PHP

Posted on 4/18/2012 at 7:00 am
Categories: Best Practices
Tags: , , , , , , , , , , , , ,

Khayrattee Wasseem (@7php) wrote at 4/18/2012 7:48 am:

Hi Brandon,
I also bought the book and I find your review is fair and correct.. Chris did a good job!

« »

Copyright © 2024 by Brandon Savage. All rights reserved.