Surgeons know they need to wash hands before operation. It goes without saying. I can't even imagine a customer (a patient in this particular scenario) convincing a surgeon not to waste the time washing his hands. These guys really now and follow their discipline.
As software engineers we sometimes fail to sell our disciple or hard skills to customers. No doubt that nowadays soft skills are as important as hard ones. Anyway let's talk about TDD discipline and the benefits it gives us:
- A documentation for the code. Working usage examples if You will.
- Less defects (no doubt).
- Smooth API (You think upfront how client code is going to look like. Is it ugly? Is it handy? etc.)
I do think that TDD discipline gives us byproducts too:
- An ability to improve/refactor fearlessly.
- A maintainable Architecture (You just can't write testable code easily without applying SOLID principles at least some of them like Separation of Concerns).
If this is not enough or You want to address people who perceive facts check out
this Research which explains benifits of TDD scientifically.
Let's set up the stage. The following Teams and Projects participated in the research:
IBM with a group that has been developing device drivers
for over a decade. They have one legacy product that has undergone seven releases since
late 1998. The three case studies at Microsoft were distributed across three of the main product families, Windows, MSN, and Visual Studio.
Metric description | IBM: Drivers | Microsoft: Windows | Microsoft: MSN | Microsoft: VS |
---|---|---|---|---|
Defect density of comparable team in organization but not using TDD | W | X | Y | Z |
Defect density of team using TDD | 0.61W | 0.38X | 0.24Y | 0.09Z |
Increase in time taken to code the feature because of TDD (%) [Management estimates] | 15-20% | 25–35% | 15% | 25-20% |
So my interpretation of the research: the results indicate that the defect density of the four projects decreased between 39% and 91% relative to similar projects that did not leverage the TDD discipline. In addition to that the teams experienced a 15–35% increase in development time after applying TDD.
Let's take into account that TDD is just one of many engineering practices You are going to apply. My experience shows that results are going to be fabulous.