Reader-supported: when you buy through links on our site, we may earn an affiliate commission. Learn more

Cover of Working Effectively with Legacy Code
Buy on AmazonBuy on Bookshop.orgListen on Audible

We earn a commission if you buy through these links. Learn more

Find Similar Books

Working Effectively with Legacy Code

by Michael Feathers

Tech
★★★★★5.0 (3)

Guide by the Books of the Day editors · Updated · How we write our guides

Feathers gives developers a practical, step-by-step way to get untested code under test so it can be changed without fear, backed by a useful catalog of dependency-breaking techniques.

What Creators Say About Working Effectively with Legacy Code

2 creators reviewed Working Effectively with Legacy Code on YouTube in 2024, with 9.8K views between them. Their opinions are their own; we picked these reviews, we didn't write them.

Michael Feathers Reflects on "Working Effectively with Legacy Code"Book Overflow on YouTube5.1K views · 2024
Working Effectively with Legacy Code and AI Coding Assistant - Michael FeathersTech Lead Journal on YouTube4.7K views · 2024

What It's About

Working Effectively with Legacy Code is a working manual for developers who have inherited code that is hard to change safely. Feathers defines legacy code pragmatically as code without tests, which shifts the problem away from age or style and toward the missing safety net. The central message is that you rarely can change untested code safely without first finding a way to test it, and most of the book covers how to get there when the code was never designed for testing.

The approach is practical and incremental. It walks through the mechanics of making a change, finding places where behavior can be altered without editing the code at that spot, writing characterization tests that record what the code actually does, and then making edits with confidence. Examples appear in Java, C++, C, and C#, but the reasoning carries over to other languages. Later sections tackle the messy cases: procedural systems, code with no obvious structure, and large classes tangled with global state.

Reading it feels like sitting with an experienced mentor who has seen many failing codebases. It is dense in places and works best as a set of recipes you return to while working, rather than a book to read once. You will likely finish with a different instinct: before touching anything, ask how you would know if you had broken it.

Read this if you…

  • have inherited a large codebase with few or no tests and need to make changes soon
  • are a working developer or tech lead who wants concrete techniques rather than abstract theory
  • want to understand why adding tests to old code is so hard and how to begin anyway

Skip it if you…

  • mainly build new systems in a modern language with test-first habits already in place
  • want a survey of software architecture or team process rather than code-level technique

Key Ideas

  1. 1

    Legacy code is code you cannot safely change

    Feathers' definition is about feedback rather than age. If you cannot quickly tell whether a change broke something, the code is legacy in his sense, even if it was written last year. This reframing makes the missing tests the core problem and gives you a concrete target: restore the ability to verify behavior before you attempt larger changes or redesigns.

  2. 2

    Characterization tests record what code really does

    When specifications are missing or out of date, you write tests that capture current behavior, even when that behavior looks wrong. The point is not to certify correctness but to create a baseline so unintended changes show up. These tests give you a way to explore unfamiliar code safely and to decide later which behaviors deserve to be fixed.

  3. 3

    Seams let you change behavior without editing

    A seam is a place where you can alter what gets executed without modifying the code at that point. Recognizing seams lets you substitute collaborators, stub out slow or external pieces, and isolate a unit for testing. Much of the book's practical value comes from learning to spot seams and to create them when none exist.

  4. 4

    A catalog of dependency-breaking techniques

    The book includes a catalog of twenty-four techniques for loosening the ties between program elements. Each is a small, mechanical step meant to preserve behavior, such as extracting an interface, overriding a call in a subclass, or sprouting new code instead of editing tangled methods. The catalog is most useful as a reference you consult when a specific class refuses to be tested.

  5. 5

    Strategies for code with no clear structure

    Not every legacy system is object-oriented, and some have no visible architecture at all. The later material addresses procedural code, large files of loosely related functions, and applications where it is hard to know where a change belongs. The emphasis is on finding a sensible change point first, then building just enough test coverage around it.

Limitations

The examples are in Java, C++, C, and C#, and some tactics reflect early-2000s tooling and language styles, so you will need to translate them to your own stack. The book focuses heavily on unit-level isolation and can feel narrow if your problems are mostly about integration, databases, or distributed services. Its definition of legacy code as untested code is useful but contested, and some readers find the dependency-breaking catalog repetitive or dense on a first pass. It says little about organizational politics, estimating, or persuading a team to fund cleanup.

Questions Readers Ask

Is Working Effectively with Legacy Code still relevant?
Yes. The core ideas of seams, characterization tests, and dependency breaking are language-agnostic and still widely used. Some examples and tool references feel dated, and modern mocking frameworks and refactoring IDEs make several steps faster. Treat the principles as durable and the code samples as illustrations of them.
How does it compare to Martin Fowler's Refactoring?
Fowler's Refactoring is a catalog of behavior-preserving code transformations and assumes you already have tests. Feathers focuses on the step before that: how to get untested code under test so you can refactor it safely. If your code has no tests, start with Feathers; the two books complement each other well.
Published
2004
ISBN
9780132931755
Difficulty
intermediate
Category
Tech

Book details and cover from Google Books.

Ready to read Working Effectively with Legacy Code?

Get your copy on Amazon, or listen to it on Audible. We earn a commission if you buy through these links.

Books Like Working Effectively with Legacy Code

View all →
Cover of Refactoring

Refactoring

Martin Fowler

Like Feathers, Fowler treats changing existing code as a disciplined, step-by-step craft. It gives a catalogue of small, behaviour-preserving moves to improve a design without breaking what already works.

Cover of Code Complete

Code Complete

Steve McConnell

A thorough, practical guide to writing and revising code that is easier to understand and change. Its detailed advice on routines, classes and defensive habits suits readers who want to improve the code they maintain.

Cover of A Philosophy of Software Design

A Philosophy of Software Design

John K. Ousterhout

Short and opinionated, it focuses on managing complexity, a theme central to legacy code work. Readers who valued Feathers's attention to what makes code hard to change will find similar reasoning here.

Cover of Test-driven development

Test-driven development

Kent Beck

The classic introduction to writing tests first and letting them guide design. It shows the red-green-refactor rhythm that Feathers relies on when bringing old code under a test harness.

Explore More