Working Effectively with Legacy Code
by Michael C. Feathers
summary article (pdf) by Feathers
review from Mark Bernstein
links to a video
This book is infinitely valuable for *anybody* who works with code they’ve inherited from others dead and gone, but it’s just as useful for anyone doing “greenfield” development. After all, most of the code you write is eventually going to become someone else’s legacy code - this book will help you see ways to ensure your code is testable in the first place and a great way to expand on what you’ve learned from Fowler’s Refactoring
. That being said, I would probably read Refactoring prior to reading this book simply to get more familiar with some of the refactorings that Feathers discusses, and *why* Feathers has such an emphasis on testable code. a review
What is legacy code?
Someone else’s code.
Difficult-to-change code that we don’t understand.
Feather’s extreme position:
Legacy Code is code without tests:
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. (p. xvi)
Legacy Management Strategy
By itself, legacy code doesn’t hurt anything. As long as it works, it only becomes painful when you have to make modifications. Fortunately, the first steps you have to take to work effectively with legacy code also make it easier to clean things up. [emphasis added]
The general legacy management strategy is:
- Identify change points
- Find an inflection point
- Cover the inflection point
- Break external dependencies
- Break internal dependencies
- Write tests
- Make changes
- Refactor the covered code.
Stack Overflow: What can you do to a legacy codebase that will have the greatest impact on improving the quality?
Object-Oriented Reengineering Patterns (see also blog ref)
[....] Code stores knowledge; it captures the history, data, needs and hopes of the original customers in a very precise and tangible medium. It’s often more trustworthy than any text or video or other formats. A lot of interpretation and guess work is still needed to understand the old code but the ability to reuse the knowledge in a very real way by linking to or modifying the old code is what makes programmers some of the most productive and valuable knowledge workers out there today. The constraints of the past provide not only a firm foundation for future work but also translate a great deal of wisdom and insight to the future. This ability to build on the past, to continually improve and refine what has come before, transforms software engineering (like science and mathematics and every other type of engineering) into a truly generative endeavor.
The Great legacy of Code
the Challenge of Maintenance Programming - article at Tech Republic
The Cost of Dead Code(approve sites)
Programming books refactoring