Infrastructure

Modernizing Legacy Systems: A Production-Grade Guide

JG

Jared H. Garr

CEO, Rebirth Distribution

Modernizing Legacy Systems: A Production-Grade Guide

Reading time: 7 min

Key Takeaways

  • Legacy systems are big balls of mud: Every new feature costs more than the last, and no one dares touch the core.
  • Domain-driven transformation works: Start with the business domain, not the code. Define bounded contexts where work changes hands.
  • Measure before you debate: Use the Modularity Maturity Index (MMI) to turn opinions into numbers and prioritize stabilization before splitting.

Let me be specific. A legacy system isn’t just old code. It’s a system that still runs the business but nobody dares to modify. Over the years, it accumulated patches, workarounds, and dependencies until every change became a gamble. Rewriting from scratch is risky and slow. So how do you modernize without blowing up production?

I’ve seen this pattern in startups and enterprises alike. The demo worked. Production didn’t. Here’s why: most teams attack the code first. They bring in tools, run static analysis, and try to refactor. But the real problem is structural. The system has no clear boundaries. It’s what Domain-Driven Design calls a big ball of mud — a tangled mess where every class depends on every other class.

The real cost of a big ball of mud

Here’s what actually happens in production: you have 463 classes spread across ten components, all interconnected. The center of the dependency graph is unreadable. You can’t extract a single class because all the others need it. Every new feature costs more than the previous one. And the worst part? The team avoids touching the core, so the system stagnates while the business waits.

This isn’t theory. I’ve seen companies burn months trying to refactor without a plan. The real cost is not just development time; it’s the incidents, the fear of deployment, and the dependency on a few senior engineers who understand the mess. That’s not automation — that’s a liability.

A four-step method that holds in production

Carola Lilienthal, managing director at WPS, presented a method called Domain-Driven Transformation at a recent conference. She used the example of a container terminal at the Port of Hamburg — a 20-year-old system they split in two years. The method has four steps:

  1. Rediscover the domain: Workshop with business experts, without looking at the code.
  2. Define the target architecture: Identify bounded contexts where work changes hands.
  3. Compare with reality: Measure the gap between target and actual code.
  4. Transform incrementally: Stabilize, reinforce, then split.

Let me break down each step with the concrete reality of production systems.

1. Rediscover the domain, not the code

Most people get this wrong. They start with the code. Instead, gather your business experts in a room and ask: What do you do in your domain, and how do you work? Don’t open the old software. Map the real-world process. For the container terminal, they traced a container’s journey from truck delivery to crane loading.

This isn’t theory. I’ve seen teams waste weeks trying to understand spaghetti code when they could have spent a day with the people who actually use the system. The domain language is the foundation.

2. Define the target architecture

Once you have the domain mapped, break it into bounded contexts — clear boundaries where the meaning of terms changes. How do you find them? Look for places where work changes hands. At the terminal, four contexts emerged: truck delivery, storage operations, storage planning, and ship loading.

Those boundaries become your target modules. But here’s the catch: your existing code probably doesn’t match them at all. That’s normal. Legacy systems were built under pressure, adding new features without adapting the old structure. The gap between target and reality is the work.

3. Measure to stop debating

Architecture discussions often turn into opinion battles. To cut through that, WPS uses the Modularity Maturity Index (MMI), a score from 0 to 10. Below 4: big ball of mud. Between 4 and 8: clean layered architecture but not domain-aligned. Above 8: domain-oriented modules.

The MMI turns opinions into numbers. It gives you a baseline and a way to track progress. This isn’t about perfection; it’s about knowing where you stand. I’ve used similar metrics in production to prioritize work and justify investments to stakeholders.

4. Transform in the right order

The transformation itself has three phases, and the order matters. Lilienthal warns: If you split a system without the previous steps, you will burn your budget.

Here’s the sequence:

  • Stabilize: Automate build and deployment, update frameworks, add tests. Low investment, immediate effect — fewer bugs and security risks.
  • Reinforce the domain: Bring code closer to the business language. Changes become safer and faster.
  • Split the system: The longest and most expensive phase. It brings autonomous teams and faster time to market.

Most people get this wrong: they jump straight to splitting. That’s like trying to renovate a house without fixing the foundation. In production, stabilization is non-negotiable. It’s the difference between a controlled migration and a 2am incident.

AI won’t do the work for you

Everyone asks: can’t AI solve the legacy problem? Give the whole codebase to a coding agent, and it will refactor everything, right? Based on experience, no. AI fails on legacy exactly where we fail.

AI looks for recurring structures to understand code. Legacy doesn’t have them — or has ten overlapping ones. Business logic is scattered, and the code needed for a task often exceeds the model’s context window. The result: hallucinated solutions with correct syntax that don’t help at all.

What AI needs is the same as what teams need: manageable, cohesive units, domain language in the code, and explainable interfaces. A study by Markus Borg and colleagues (published January 2026) confirms: the healthier the code for humans, the better AI refactorings. So before you throw an AI agent at your legacy monolith, make sure it has clear boundaries. Otherwise, you’re just automating the creation of more mud.

The bottom line

Building new on top of old works, but you have to do it in the right order. The Domain-Driven Transformation method is not a silver bullet, but it’s a production-grade approach. It starts with the business, measures objectively, and stabilizes before splitting. The real cost of skipping steps is measured in incidents, team burnout, and missed deadlines. Let me be specific: if you’re facing a legacy system, don’t let your team debate architecture for months. Get the domain experts in a room, map the business, and then use metrics to guide the transformation. That’s how you turn a liability into an asset.

This isn’t theory. It’s what works in production.

← Back to Latest