Chapter 9

Testing Legacy Code

Code without tests is bad code. It doesn’t matter how well written it is; it doesn’t matter how pretty or object-oriented or well-encapsulated it is. With tests, we can change the behavior of our code quickly and verifiably. Without them, we really don’t know if our code is getting better or worse. To me, legacy code is simply code without tests.

– Michael C. Feathers, Working Effectively with Legacy Code

Once upon a time, a friend who was very skilled in the subjects of this book went to a job interview for a consultancy in a large company. They gave him an exercise about refactoring some legacy code. He created a seam and used it to solve the exercise in a way they had never seen before.

At first, they wanted ...

Get Agile Technical Practices Distilled now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.