Building Software with TDD vs Without TDD
The content here is under the Attribution 4.0 International (CC BY 4.0) license
For a long time, I have been reflecting on the differences between developing software with Test-Driven Development (TDD) and without it. My experience working with various clients and projects has led me to write this post to share my thoughts on balancing technical practices like TDD with the real day-to-day of software development.
Challenges in Software Development
In the software development process, I’ve observed that many teams struggle to balance delivering business value with maintaining the well-being of their developers. This imbalance often leads to burnout, high employee turnover, and long-term damage to the business.
Interestingly, many teams claim to follow Agile practices but fail to implement them effectively. This lack of adherence to proper processes, combined with the absence of TDD or the lack of technical practices to deal with technical debt, creates a vicious cycle of inefficiency and frustration, ineficiency and poor outcomes.
The Role of TDD
TDD is a practice that can help address some of these challenges. It emphasizes incremental development, collaboration, and a focus on quality. The three stages of TDD (Red, Green, Refactor), align with Agile principles by promoting:
- Incremental development
- Clear communication of requirements, and if not, it helps to expose the lack there are of clarity in them
- Awareness of potential pitfalls in the automation of tests cases
By adopting TDD, teams can uncover hidden issues in the business logic and reduce the number of defects that impact end users. While TDD doesn’t eliminate all problems, it helps prevent many of them, leading to a more stable and maintainable codebase. When test cases are generated thinking on the refactoring aspect of the code base it gives an extra boost on the value perceived by developers.
Common Misconceptions About TDD
One of the biggest challenges I’ve faced in the industry is helping developers understand the value of TDD. Many developers expect TDD to be a “magic pill” that instantly eliminates bugs. However, TDD is not magic—it’s a discipline that requires time and effort to see results.
In my experience, it can take 1 to 2 years to notice significant improvements from TDD. While defects are reduced over time, developers often struggle to see the immediate benefits, which can lead to frustration and resistance.
In addition to that, Janzen and Saiedian conducted a study with 500 companies to investigate further the influence that TDD has on code design [1] . In that, they found the following miss conceptions:
- TDD Equals Automated Testing: Some developers mistakenly believe that TDD is solely about writing automated tests.
- TDD Means Writing All Tests First: There is a misconception that TDD requires developers to write all tests before coding, rather than using the iterative approach of writing tests and code in short cycles.
For 2, I would elaborate further in another post to share my thoughts on the iterative apporach of TDD and relationship with the test cases created first. The authors argue that the main purpose of TDD is to design, is it?
A Bottom-Up Approach to TDD
When introducing TDD, I prefer a bottom-up approach. This means starting with small, incremental changes at the technical level rather than imposing top-down mandates. While this approach can place a heavier workload on technical leaders, it allows teams to gradually adopt TDD and build confidence in the practice.
It is worth mentioning that in my experience the bottom-up approach needs a sponsorship from the top management, otherwise it will be hard to convince the team to adopt TDD. The sponsorship can be in the form of time allocated for training, mentoring, and support from management.
Conclusion
TDD is not a quick fix, but it is a valuable tool for improving software quality and reducing defects over time. By focusing on incremental adoption and addressing misconceptions, teams can integrate TDD into their workflows and achieve long-term benefits. At this stage, I haven’t yet found a replacement for TDD that brings the same values while developing software as TDD does. However, I am still open to exploring other practices that can complement TDD and enhance the software development process.
References
- [1]D. Janzen and H. Saiedian, “Does test-driven development really improve software design quality?,” Ieee Software, vol. 25, no. 2, pp. 77–84, 2008.