New Onboard is here — AI-guided, self-hosted onboarding for your codebase. Learn more
Features Code Navigation Static Analysis Graphs Compliance Metrics Custom API How it works FAQs Pricing Docs Start free trial
Book notes

I read Working Effectively with Legacy Code. Here's what you need to know.

Managing legacy code can be intimidating and difficult. Michael C. Feathers details how to get the most out of working with legacy code.

“To me, legacy code is simply code without tests.”

Working effectively with legacy code

I have 5 million lines of legacy code… and that's okay!

I'm Ken. My team maintains 5 million lines of C++ code, some of it 25 years old and touched by 35 different programmers.

I read Working Effectively with Legacy Code, and I heartily recommend it. It offered hundreds of nuggets; some I knew, some new to me.

The central theme of the book is that legacy code is not just code you didn't write, it's code that isn't associated with tests. The challenge to getting legacy code under control is to make it tested, sometimes refactoring, rearchitecting, restructuring.

  • Legacy code should be testable
  • Legacy code can be manageable
  • Using the right tool can help you manage legacy code
The cover of Working Effectively with Legacy Code by Michael C. Feathers.
Working Effectively with Legacy Code by Michael C. Feathers.
Here's how to do it

Read, document, and only then change

What the book asks for, and what we do every day on our own codebase.

Read legacy code and document what you learn as you go

Yep — the building blocks for working effectively with legacy code are reading legacy code, thinking about legacy code, and writing down what you learn. For yourself. For future you. For others.

Once that is in hand, for any part of the legacy code, you proceed on with test writing, refactoring, restructuring and rearchitecting as needed. Here's the cool part: even if you don't write tests, understanding your legacy code before you touch it is really useful.

Understand's editor window with legacy source code open beside its cross-reference information.

How we read and understand our 5 million lines of legacy C++

We wrote a tool. It's called Understand. As I read the book, I realized I'd spent the last two decades working on the key skill the book required.

In a bit of dog-food-eating karma, we use Understand to maintain Understand. Day in and day out, our engineers can't imagine using anything else. And because we maintain — that is, read and try to understand — our own legacy code with it, it's pretty darn good at it. You can try Understand for free on Windows, Mac and Linux. And you should.

The Understand main window, with a source file, its cross-references and a generated graph open together.

How's it different than my current IDE?

Understand is aimed at reading, browsing, and understanding legacy code. Most IDEs are about generating code, code colorization, and some have debugger integration.

Understand, at first glance, looks like other IDEs. Code colorization. File browsing. Auto-completion. But under the hood — and via the power of click synching and information pushing — Understand optimizes reading and thinking about legacy code, knowing exactly what is connected to the code you are reading. It's for grinding down connection chains, learning, and then backing up to where you started to start on the next line.

We use it for virtual debugging: stepping through code thinking about it, then backing up and thinking more down other paths. That's how you understand legacy code. It's how you fix bugs. It's the start of all refactoring. It's the knowledge building process of doing safe maintenance of code. This is all based on our unique and hard to do Hyper-Xref technology.

An Understand editor window showing a function alongside the entities it is connected to.

The importance of documentation

As you learn about your legacy code, you can use annotations — like Word or Google Doc post-it notes — to document what you learn.

Along the way, as you explore, document the architecture from the bottom up as it is actually built, versus as intended. Share that with everyone, and get what they discovered too. That turns no architecture into shared, understood, and useful legacy code architecture. This is just the tip of the iceberg about what Understand does to help you think about your code. So download it, and give it a try today.

Annotations attached to code in Understand, recording what an engineer learned while reading it.
Get started

Try Understand for free today

Our free trial enables all features that can be used on a sample code base.

Windows, Mac and Linux.