Test-Driven Development kata experiences
17. Feb 2013I've been doing the Roy Osherove's string calculator TDD-kata in:
- PHP
- Java
- C# via Mono
Basically after the first go-around I had working code in one method and had tests covering. The real eye-opener was when I refactored the one method into more reasonable pieces. The unit tests provided very nice safety net, so I knew that my program still works as specified even after modifications. Naturally one move after refactoring would be to add tests to cover those additional methods.
With legacy PHP code where there is no automated testing at all, the refactoring required for TDD makes it propably non-starter. I guess the correct way to proceed there would be to write all the new code with tests and perhaps upgrade the old code in small pieces when changes are required.