I had this funny thought that what if you have a GPS that tells you that you made a wrong turn only after you made a turn (I know no one will use one like that), what will happen?
Lets say you are driving around with this kind of GPS and reached an intersection. You made a right turn and the GPS beeped that it is a wrong turn. What do you do? If you are in India, you just reverse your car and take a different choice. If you are in US, you may have to find a “U” turn and come back to the intersection and then make another choice.
When we don’t do Test First Development this is how it feels like. Every time a bug is found, developer needs to figure out what and where to fix. This could take a significant amount of time, depending on how well the code is designed. Of course, GPS is pre loaded with maps and a developer needs to create his own GPS (executable tests) before starts his journey (coding).
Once a bug is found, developer has two choices:
1) Some how quickly fix it. This is very likely, if the code is not well factored, since it could take lot of rework to fix the bug. If the developer is in a hurry, he wants to patch it up and move on. This is like in Indian scenario above where you could bump into on coming traffic or someone and create a bigger mess, that leave the code in an undesirable state.
2) Take the right path by re-factoring the code and place the fix , which takes longer.
Test First development helps reduce number of bugs since the code is driven by executable tests and also helps fixing the bugs, if found, easy since the code is better designed. Here the tests are the GPS for coding and helps you reach your destination faster.
Hope, this makes sense!