Khangharoth

October 16, 2011

TDD Red-Green-Refactor – Missing Refactor step

Filed under: Software Design — khangharoth @ 3:24 pm

The code base of our project does not  look any bit like Uncle Bob’s  clean code examples – Why ?

This question was in my mind for long –

In spite of doing TDD where everyone writes tests first then why our code base is still sub standard ? Why we have lots of disjointed test cases and code base which is not cohesive ?

Initially the answers I was getting from myself were :

a) May be what works for  a simple one class problems don’t scale for big projects.

b) But then their are parts of our System which are beautifully written(done by a individual ) – So this process is working for  some and not for others .

What if those guys would anyway write better code than rest of us – be TDD or not ?

With all these questions in mind – I took  a SVN update to start on a Jira (bug) . When I looked at the relevant class  – It took me around 10-15 mins to understand what it was doing and the fact that it had test cases made no difference in my ease of understanding that piece of code.

How can we invariably ends up with something like this – Even though we are doing everything right ? – I went through svn check-in history something  struck to me – We Are Missing The All important step of Refactoring !

When we learn about TDD – its being taught as Three Simple Steps

RED – Green -Refactor

But when we started using it , we reduce it to just two step !

Red-Green  , Red-Green , Red-Green – The important step which binds everything together and which gives shoulder to the Simpleton Advice (do the simplest thing to make the test pass) to stand on , Refactoring, is actually being forgotten .

If you and your team is new to TDD process – Make sure that you are also not missing the integral step of Refactoring !

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

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

Blog at WordPress.com.

%d bloggers like this: