Working Effectively with Legacy Code
I’m attempting to strengthen a weakness in my knowledge; that weakness is making changes to legacy code with a high degree of confidence. As Michael Feathers puts it in his book Working Effectively with Legacy Code, Legacy code is simply code without corresponding tests. It doesn’t have anything to do with when the code was written or what language it was written in; legacy code is code without tests, often poorly implemented. As Feathers says, someone may be writing legacy code on your project right now.
To make timely changes to an app with confidence, unit and functional tests are necessary. Still, the biggest problem is implementing such tests on a system that wasn’t designed with that in mind in the first place. To introduce tests, it seems you have to change code, sometimes lots of code, but if you don’t have tests already, how can you do that with any confidence? Over the years, the strategies I’ve learned only cover about 20% of the cases, leaving about 80% to slow coding and lots of repetitious manual testing.
So far, this book has changed my definition of what legacy code is and provides many solid techniques to improve existing codebases.