HN
Today

Use the Mikado Method to do safe changes in a complex codebase

The Mikado Method offers a structured approach to tackling daunting changes in complex, 'spaghetti' codebases. It advocates for breaking down large refactoring tasks into small, reversible, time-boxed steps to avoid getting stuck in a 'quicksand' of failing builds. Hacker News found it a practical, albeit sometimes re-packaged, strategy for a common developer pain point: making safe changes without breaking everything.

14
Score
8
Comments
#8
Highest Rank
8h
on Front Page
First Seen
Mar 2, 3:00 PM
Last Seen
Mar 2, 10:00 PM
Rank Over Time
14891314151926

The Lowdown

The article introduces the Mikado Method, a strategy designed to help developers make safe and valuable changes within challenging, often poorly documented or untested, legacy codebases without falling into a spiral of compounding errors.

  • The Problem: Working with large, complex codebases can feel like 'quicksand' where fixing one issue creates two more, leading to stalled progress and eroding trust.
  • The Mikado Principle: Like 'eating an elephant one bite at a time,' the method emphasizes breaking down big goals into manageable, smaller pieces, inspired by the pick-up sticks game.
  • The Process: Developers start by setting a main goal. They then attempt to achieve it within a short timebox (e.g., 10 minutes). If unsuccessful, they revert all changes, identify a missing subgoal (what needs to be done first to make the main goal easier), write it down, and repeat the process with the subgoal. If successful, they commit the change and mark the subgoal as complete. This iterative process continues, tackling 'leaf' subgoals first, until the main goal is easily achievable.
  • Key Advice: Keep timeboxes short (e.g., 10 min) to avoid the sunk cost fallacy, commit every successful subgoal as a checkpoint, and apply the method especially to ambitious refactorings.
  • Origin: The method is named after the Mikado pick-up sticks game, where the goal is to remove a specific stick without disturbing others, much like untangling dependencies in code.

By systematically identifying and addressing prerequisite subgoals through small, committable iterations, the Mikado Method aims to transform overwhelming codebase changes into a series of achievable, safe steps, ultimately making developers more efficient and preventing major project setbacks.

The Gossip

Naming Nuances and Naysayers

Many commenters debated whether the Mikado Method is a novel technique or simply a re-packaging of well-known practices like timeboxing and incremental changes. Some viewed the 'slapping a cool word' approach as pretentious, while others acknowledged that framing existing concepts can still be valuable, especially if it emphasizes a specific, iterative approach to planning.

Legacy Code Lifehacks

Beyond the Mikado Method itself, the discussion broadened to practical strategies for dealing with legacy codebases. The crucial role of comprehensive testing was highlighted as a stress-reducing safety net. Some also pointed out real-world constraints like the 'luxury' of using a compiled language for early error detection or the common scenario where refactoring budget simply isn't available.

Methodological Musings and Modifications

A few commenters shared their personal experiences and adaptations of the Mikado Method. One user detailed their system using git commit ordering and pre-commit hooks, noting the persistent challenge of resisting the urge to *not* fully reset between 'iterations' to avoid messy state transfers, a core tenet of the original method.