What do test first development and dental floss have in common?

Posted On November 3, 2009

Filed under Testing
Tags: , , , ,

Comments Dropped leave a response

Yes I am going to write another blog posting singing the praises of test first development (be it TDD, BDD or whatever DD is cool now).  What will be new is that I’m going to compare it to something that I avoided doing for almost 36 years on this planet, flossing my teeth regularly.

Six months ago I was told by my dental hygienist that my gums were not doing so well in terms of health.  This made for a somewhat uncomfortable (ok it was downright painful) dental cleaning.  She said that flossing was really the key to keeping my gums healthy, keeping my teeth in my mouth and making visits to the dentist more “enjoyable”.  I took it upon myself to help myself by flossing more regularly.  Yes I missed a couple of days but for the most part I flossed every day.  It really only takes 5 minutes at most to do a good job in there…which you can easily make up by reading 5 less minutes of the Internet (or at least this is how I found the time).  Today’s cleaning was a breeze compared to last time.  Yes it was still a little uncomfortable but nothing compared to the last time.

So what does this have to do with test first development?  We’ll just this morning (before the dentist’s visit) I was in the process of refactoring a bunch of Rails code to add a new object hierarchy for some new requirements.  To make a long story short, my refactoring broke a bunch of code (as one would expect).  Thanks to our suite of existing spec code, I now had a laundry list of tasks that were needed to properly integrate the new code.  After addressing all of them and tweaking some views (we don’t have view specs but hey nobody is prefect), I fired up the app and it all just worked.  Until I started working on Rails sites, all of that spec code would not have existed.

I couldn’t imagine what might have happened had we not taken the TFD (test first development) route with this project.  Yes it takes a little more time up front to write the tests (just like flossing) but the next time you have to do some major work in your application (which is regular just like visiting the dentist’s office)  the experience won’t be as painful as it could be.

Today’s experiences with TFD as well as the dentist office have made me a firm believer that both regular TFD and regular flossing makes my life a little easier.  I vow to no longer look at writing tests as wasted time but an investment in pain saved down the road.  I hope that anyone that reads this either starts doing test first development, or maybe even flosses a little more regularly and uses this analogy when preaching the wonders of TFD.

— Mike Gehard

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s