4 ms·
TDD helps you think about the API as a user, which naturally leads to a user-friendly design, and in turn also makes the implementation testable from the start.
by imiric 3y ago
TDD helps you think about the API as a user, which naturally leads to a user-friendly design, and in turn also makes the implementation testable from the start. Often when testing is done after the implementation, the code is tightly coupled, relies on external state, and requires refactoring just to make it testable.
That said, this workflow is tedious during the exploratory phase of the project. If you're unsure yet about which entities should exist, and how they will be used and interact with each other, TDD can be a hindrance. Once the design is mostly settled, this workflow can be helpful, but insisting that it must be used always is also annoying. Everything in software development is a trade-off, and dogmatism should be avoided.