Fixing Bugs in Legacy Code
Sometimes we have to fix a bug in code that was not developed using TDD and has no tests.
What I do this is to use one of the main principles of TDD and start with a failing test.
This failing test should replicate the bug report.
Then when you fix the code, the test should pass.
Sometimes when looking at an ‘old’ piece of code in can be tempting just to try and fix it.
But make the effort of adding a testing framework and the first test. You and your colleagues will benefit in the long run.
The code will gradually become more stable and more maintainable.
This principle can also be used when adding new functionality to an existing application that was developed without TDD.
Saturday, 19 September 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment