Saturday, January 27, 2007

One activity that is inherently productive: unit testing

In a post today in his blog, Larry O'Brien states: "...let's be clear that of all the things we know about software development, there are only two things that we know to be inherently highly productive: Well-treated talented programmers and iterative development incorporating client feedback"

I find it hard not to add unit testing to this list.

Of all the things that have changed in how I program during the last six or seven years, nothing comes close to unit testing in terms of making me more productive. In addition, it has made me a better programmer, because as I write code I am thinking about how to test it. And the changes that result are almost always improvements.


David Dossot said...

Interestingly, while adding new features to one of my open source projects today, I was contemplating how much unit testing has modified my way of doing things (and this, of course, for the better).

For example, as I was adding features to the main API, I went like this:
- modify the interface,
- add empty stub methods in implementation,
- write tests for the new features, which all fail,
- replace the stubs with actual methods,
- enjoy green lights.

God knows how I would have done this a few years ago... I simply might have not dared touching anything!

Andy said...

Yeah, I agree with you, Andrew. As Martin Fowler said of JUnit-- "Never in the field of software development was so much owed by so many to so few lines of code."