Course contentsShow
← Software Engineering
Lesson 1755 of 1,93351. Legacy Code and Brownfield DevelopmentFree lesson

The Mikado Method

A structured approach to making large-scale changes by mapping prerequisites and working incrementally toward a goal.

The Mikado Method

What you'll learn: How to systematically refactor or change complex legacy code by mapping out all prerequisites before attempting the final goal.

The Core Idea

When you try to make a large change in legacy code, you often discover that it breaks dozens of things. The Mikado Method gives you a disciplined way to handle this: instead of fixing everything at once (and getting lost), you map out what needs to change first, revert your breaking change, then tackle prerequisites one by one until the path is clear.

Think of it like planning to move a heavy piece of furniture through your house. You discover the doorway is too narrow, so you need to remove the door. But removing the door requires unscrewing hinges, which requires finding a screwdriver. The Mikado Method says: write down all these steps as a graph, then work backward from the small steps.

How It Works

  1. Try your goal change — make the big refactor you want
  2. Observe what breaks — compilation errors, test failures, etc.
  3. Revert your change — go back to working code
  4. Draw a graph — your goal is the root; broken dependencies are child nodes
  5. Pick a leaf node — tackle the smallest prerequisite first
  6. Repeat — for each prerequisite, try the change, find new prerequisites, revert, and map them

You end up with a tree diagram (the "Mikado Graph") showing the order of changes needed. Each change is small, testable, and keeps the system working.

Why It Matters for Legacy Code

In legacy systems with tight coupling (see lessons 1753-1754), you can't just "make the change." The Mikado Method prevents you from ending up in "refactoring limbo" with a broken codebase for days. You always commit working code.

Key Takeaway: The Mikado Method structures large legacy refactorings by discovering and mapping prerequisites incrementally, ensuring you always maintain a working system while moving toward your goal.