liveBook · Manning

Chapter 7: Taming legacy code

What you will learn in chapter 7 of Build High Value Software Systems

The introduction defines legacy code by how safely it can be changed and explains why it disrupts development flow.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction defines legacy code by how safely it can be changed and explains why it disrupts development flow.

Key terms: legacy code, safety to change confidently, decision inventory, safety nets, feedback loop, flow

7.1 Understanding legacy code through a Lean lens

This section treats legacy code as valuable production software and teaches an investigation sequence for uncovering its behavior and business constraints before changing it.

Key terms: legacy code, gemba, runtime behavior, logging, debug mode, tests, trace backward from the symptoms, business logic, constraints, business constraints

7.1.1 Two traps

The section warns against wholesale rewrites and unchecked AI-generated code, and argues for incremental improvements that preserve flow and create safety nets.

Key terms: rewrite fantasy, small-batch Lean thinking, flow, work-in-progress inventory, AI accelerates legacy creation, decision inventory, safety nets, clear boundaries

7.2 Identifying and prioritizing waste in legacy code

This section shows how to identify legacy-code waste by connecting code smells to their effect on development flow, then measures how a focused change can reduce that waste.

Key terms: code smells, TIMWOODS, overprocessing waste, overproduction waste, inventory waste, long methods, high-churn, cognitive load, singular responsibility, cohesive responsibilities

7.2.1 Prioritizing waste by impact

This section shows how to prioritize legacy-code cleanup by its effect on development flow and the likely return on the time spent fixing it.

Key terms: change frequency, friction per change, flow impact, frequency versus friction matrix, high-churn files, developer surveys, PR cycle time, friction score, bottleneck, constraint

7.3 Lean design principles for legacy code

This section explains why legacy-code design patterns should be judged against current sources of friction, with principles guiding which structures to keep, simplify, or remove.

Key terms: design patterns, standard work, Model View Presenter (MVP), constraint, value stream, design principles, forces, abstraction, real demand

7.3.1 YAGNI as a Lean design principle

This section applies Lean pull thinking to legacy-code design: add structure when a real requirement creates friction, not in anticipation of one.

Key terms: YAGNI, pull-based design, real demand, observable friction, production behavior, conditional, notification paths, dispatch structure, generator function, callables

7.3.2 Lean perspective on design patterns

The section applies a Lean test to legacy-code design patterns: use structural changes where they reduce real friction, and replace systems in small, verifiable steps rather than one risky rewrite.

Key terms: SOLID principles, SRP, high-churn paths, change frequency x friction, seam, external dependencies, mock, pull-based principle, YAGNI, Strangler Fig

7.4 Attacking a legacy codebase systematically

The section shows how to make legacy code safer and faster to change by capturing its current behavior before refactoring.

Key terms: characterization tests, automated baseline, code coverage tools, approval testing, golden master, semantically, AI agents, edge cases, test matrices, flow enabler

7.4.1 Technical debt

This section reframes technical debt as a tradeoff to prioritize by its cost of change and reduce through small improvements embedded in daily work.

Key terms: technical debt, interest rate, change frequency, friction per change, Git, retrospectives, friction, Kaizen, refactoring, PR

7.5 Exercise: Tame one legacy module this release

The exercise guides readers to improve one high-friction legacy module safely, then repeat the approach in later releases.

Key terms: constraint, change frequency, friction per change, high-interest debt, gemba, hidden business rules, characterization tests, boundary conditions, smallest change, highest interest friction

7.6 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 6: Flow in your development cycle Chapter 8: Root cause thinking for developers →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.