Table of contents:
Part 7 – Conclusion (This post)
Often when talking about TDD it is said that despite of its name, TDD is not a testing methodology, but rather it’s a design methodology. As you’ve seen in this series of articles, the SOLID principles goes hand-in-hand with TDD, and indeed TDD drives the design of your code in a way that adheres to the SOLID principles. These principles ensured that each class in your code is loosely-coupled and reusable, which makes your application highly maintainable.
Even though you can write code that adheres to the SOLID principles, and also write unit tests for them in afterthought (not TDD), it is much more likely that you’ll get it right if you write the tests first, because the tests forces you to design your class to be isolatable, and thus reusable and loosely coupled.
In addition, the existence of well-written tests allows you to refactor your code much more easily and improve it to adhere to the SOLID principles even if they’re currently not 100% compliant.