As a developer, there is a high chance that you had a debate on the value of TDD in building software, especially if you apply it!
I had a lot of those debates!
A couple of months ago, I came across such a debate between Jim Coplien and Robert Martin (Uncle Bob). I found this discussion kind of interesting especially that it involves two leaders in software engineering.
You can watch the debate here:
Here are my takeaways from the discussion:
Three Rules of TDD
Uncle Bob defines the following three rules for applying TDD:
- Don’t write a line of production code without having a corresponding failing test
- Don’t write too many failing tests without writing production code
- Don’t write more production code than is sufficient to pass the currently failing test
Architecture is Important
Jim points out that he has no problem with those rules, his concerns are more architecture related. Jim and Uncle Bob would argue for more than ten minutes to finally reach an agreement on the importance of architecture. The below five points summarizes what they agreed on:
- Architecture is very important
- It is entirely wrong to assume that the code will assemble itself magically just by writing a lot of tests and doing quick iterations
- Design evolves with time and should be assembled one bit at a time
- An Object should have properties to give it meaning. At the beginning, those properties should be minimal.
- Architecture shouldn’t be created based on speculation
TDD and Professionalism
Probably the only disagreement you can sense from this debate is what defines a professional software engineer. For Uncle Bob, it is irresponsible for a software engineer to deliver a single line of code without writing a unit test for it. Jim, on the other hand, considers ‘Design by Contract’ to be more powerful than TDD.
My Point of View!
Personally, I have been applying TDD since I joined my team three years ago. After experiencing the benefits of this practice, we got to a point where we don’t write or refactor any line of code without having a corresponding unit test!
All that makes me say that I agree more with Uncle Bob on the topic of professionalism!