Skip to main content

Sanitary Software - OMG PLZ wash ur hands!

Posted by emeade on January 16, 2005 at 11:19 AM PST

Last month, I gave a no value added link to Kent Beck's Future of Developer Testing. Dominique put up some great notes on the talk and got me thinking a bit more about Barriers to Developer Testing and the cost of unit testing.

Watching the Extreme Programming Yahoo Group, I've seen XPers make statements that comparing lines of production code vs. lines of test code it comes out near 1:1, which pretty much matches my experiences.

If a "perfect" system, with no tests, was compared to a TDD system and it came out around 1:2 writing tests might seem double the work, but I haven't seen many perfect systems. I have seen a lot of unrefactored, un-unit-tested legacy systems. It is pretty common to see cut-n-pasted code repeated 4, 5, even more times. Using 3 (three strikes and you refactor) and then comparing a perfect system, with a TDD system, to the typical legacy apps I have seen, you get 1:2:3. Seems to me that in non-perfect conditions, not writing tests invites more lines of code not less. Maybe that is one reason why people report TDD is faster?

Tests are important to your software's health. Unit tests help keep bugs out of your system, much like how health care professionals keep bugs out of you by washing their hands and using gloves, well 40% of the time

Related Topics >>