Friday, October 13, 2006

Road to Test Driven Developement:Part-I

Test Driven Development or TDD! A well framed buzz spawned by some agile programmers advocating extreme programming or a reality? I think it needs to be evaluated and then absorbed.Write Test, Run Test, Write Some Code, Run Tests Again, the process seems very exaggerating, over used.

Many programmers including me(though i don't write much) will be haunted by the idea of writing tests for the code we write and developing a final piece out of tests, even more dreadful.We always have cared about writing down the logic, we are just a gang of logical master minds, we don't care about documentation, beauty of the code, its maintainability.And when some body finds a bug in our system, we just yell out "How the hell it can happen"! May be its the right time for people like us to grow up..Nothing is there in this world not worth of giving a try.So I fix my head towards the road to TDD.

Writing software is like telling a good story, you design every character and every situation very carefully so that the story can go on without loosing its root( backward compatibility) and off course grow.Alike, every piece of code, every method, the flow of a project should be designed wisely.Test driven Developement is a way or we can call it a style of developing a software , it is not just how we write code but how we assemble many small pieces of code to make a complete running software that will bring smile to the customer.

TDD has been around since 2000, but it could not reach the heart of development process.Many companies still place testing after the design and development phase.Result? they pay high price for refactoring even for a small change.Some have incoorporated the style but not promoting it.We need a lion's share of the developer community to get TDD in to the main stream.

Verifying and scrutinizing the work we do plays a crucial role, we have been verified and scrutinized right from early school days.Without testing, the code which seems to work fine today may give you nightmare tomorrow and why? you will spend another week to find out.So the best and safest corner in the town is, go for "Test,Code, Test" until you succeed.But again why?

Tests saves your time, not during writing the tests but during regression period.A small change in code may break some major part.If you follow fine grained testing strategy, you can just run your unit tests and see which block busted.Refactoring you cannot avoid because customers are never happy.TDD gives you the edge, its a programming technique which ensures that your code is properly unit tested.

The most important and striking outcome that you get following test driven coding is confidence. The developers are more confident when they check in their code at the last moment of product release.Why? because they have had tested their code right to the method level for all possible disaster.Developers follow more cohesive, loosely coupled component architecture which can be easily tested with the side effect that the components can grow of their own and they can be integrated to a larger system.

And the most important things, the managers saves money! Developing a software from scratch is cheaper than refactoring it afterwards. So you pay little now or you pay huge later.

In the next part, I will try talk something useful about the approach to be taken for TDD.