Member-only story
Gradually Transforming All Legacy Code with TDD
Can you do TDD With Legacy Code? What kind of strategies can you follow?
I have done several talks about TDD, and I have been helping several teams to start working with TDD. And almost every time I receive the same question: If my legacy codebase does not have any developer tests, how can I start doing TDD?
How TDD Works?
TDD is a style of programming that combines coding, testing, and design. It works as a discipline, in which the programmer follows three rules:
- The developer writes the test before implementing the code, until the test fails.
- The developer writes the minimal amount of code that makes the test pass.
- While making the tests pass frequently, the developer refactors the test and production codes.
These three rules repeats frequently, executing the tests several times each minute. While following the Agile principle of simplicity (the art of maximizing the work not done), these rules aim to reduce the Technical Debt.
Legacy Code
The term «Legacy Code» usually refers to an old code that is no longer in active development, but sometimes it also can be understood like code without…