- We design and build extraordinary applications for companies looking to make the next great idea a reality.
- learn more
Test-Driven Development As Part of the Process
About a year ago, I wrote this post about test-driven development,
which has some tips for TDD from a developer point of view. I thought I’d
augment that a little bit by offering some thoughts about TDD from the larger
project perspective.
The Long Term Starts Tomorrow
There’s a general sense that automated testing is something you do that costs
you time in the short term for a long term benefit. This is probably true to
some extent, although I’d argue that if you are really seeing a short term
time loss from TDD, then you probably could improve your practice some.
The larger point is that referring to “the long term” makes the benefits seem
like something that will happen in the comfortably remote future, along with
flying cars and space elevators. Usually, though, the long term starts the
first time somebody asks you to add a feature or fix a bug. Which means next
week. Or tomorrow. Or later today. The benefits accrue faster than you think.
Retrofitting for Tests Never Quite Works
There aren’t a whole lot of programming tasks in the agile world that are as
as annoying and frustrating as adding unit tests to existing code. The
existing code never has all the structure and hooks needed for good testing,
which means refactoring is needed to get any useful testing in. Of course, the
existing code doesn’t, by definition, have tests, so there’s danger involved.
Inevitably, there’s some monstrously hairy corner of the code that nobody
wants to touch and it just hangs there, untested. You’ll almost always also
see that design decisions that were not made with testing in mind are not
particularly amenable to allowing unit testing later on. The cost of
retrofitting accrues faster than you think, as well.
Refactoring is Just As Important
The test-driven development process is a three step process. Test, code,
refactor. The refactor step gets left off sometimes, but it’s just as
important as the other two in getting the full benefit of TDD. There is an
analogy to continuous integration, where the idea is by integrating in more
frequent, smaller chunks, the overall integration costs go way down.
Similarly, by doing frequent, small refactoring, overall cost of refactoring
to keep the code clean goes way down. It helps tremendously to do the
refactoring in the tight loop, when you are most familiar with the code and
the tests you’ve just written.
Leave a comment
About Pathfinder
Recent
- Thanksgiving 2008: What We’re Thankful For (In Rails)
- iPhone SDK: Testing with TextMate & GTM
- GWTQuery - JQuery-like Syntax in GWT
- Ask the readers: How do I fire native browser events in Prototype.js?
- News Rollup for the Week of November 17, 2008
- Rails ThreatDown!
- Automated Deployments Rock
- Bandwidth profiling Flex projects and more with Charles
- iPhone SDK: UIViewController Testing & TDD
- Icons are evil; so are menus - unless you do them right
Archives
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006

