
The right answer is usually neither pure refactoring nor a full rewrite. It is incremental replacement: keep the system running while you move the parts that are holding the business back. But that answer only becomes obvious after you understand why the current system is failing.
Refactor by default. Rewrite when the architecture, platform, or economics make incremental change more expensive than replacement. The hard part is recognising which situation you are in.
Refactor vs rewrite, defined
Refactoring changes the structure of code without changing its behaviour. A rewrite replaces the system, or a substantial part of it, with a new implementation. The distinction matters because the risks are different: refactoring risks breaking behaviour slowly, while a rewrite risks losing behaviour all at once.
When refactoring is the right default
Refactoring is usually the better path when most of these are true:
- The core architecture still fits the business, and the problems are localized.
- The platform and runtime are supported, with a credible upgrade path.
- You can add tests or characterization tests around the areas you need to change.
- The team understands the domain well enough to separate essential complexity from accidental complexity.
- The system can be improved in slices while it continues to serve customers.
In these cases a rewrite converts a series of manageable changes into a single, high-variance bet.
When a rewrite is justified
A rewrite can be the rational choice when the current system cannot meet a known requirement at a reasonable cost:
- The platform is end-of-life, unsupported, or impossible to secure.
- The architecture cannot satisfy a core requirement such as multi-tenancy, real-time processing, or regulatory isolation.
- Every change requires workarounds that cost more than replacing the affected area.
- Hiring and onboarding are constrained by a stack the market no longer supplies.
- The business model has changed enough that the original boundaries no longer make sense.
- A bounded slice can be replaced independently, with a clear cutover plan.
Notice that most of these are business and constraint arguments, not aesthetic ones. 'The code is ugly' is not a rewrite case. 'The code prevents us from entering a market we can serve profitably' might be.
The costs most rewrite cases miss
- Feature parity: the old system contains years of undocumented behaviour that customers depend on.
- Dual maintenance: during the transition, both systems need fixes, security patches, and operational attention.
- Opportunity cost: the team building the replacement is not shipping new value.
- Second-system effect: the replacement tends to absorb every feature the team ever wanted, which expands scope.
- Data migration: history, identifiers, permissions, and integrations are usually harder than the application code.
- Morale and retention: long rewrites without visible progress are a common reason engineers leave.
A decision framework
Answer these questions honestly before committing. A single yes does not justify a rewrite; a pattern of yes across the first four is a strong signal.
- Is the current architecture preventing a specific, valuable business requirement?
- Can the problem be isolated to a slice, or does it affect the whole system?
- Do we have enough tests, documentation, and domain knowledge to define parity?
- Is the platform unsupported or uneconomic to keep running?
- Can the scope be bounded, or is it already expanding before work begins?
- Is there an incremental path that delivers value before the old system is decommissioned?
- Can we run both systems in parallel and migrate traffic gradually?
- Do we have the engineering capacity to sustain the current system while building the next one?
The middle path: incremental replacement
The safest modernization pattern is the strangler fig: route traffic through a facade, replace one capability at a time, and decommission the old path when the new one is proven. Martin Fowler documented the pattern long before it became the default recommendation for legacy systems.
- Put a routing layer in front of the current system so behaviour can move without changing every consumer.
- Choose a slice with clear boundaries and real business value, not the easiest module.
- Migrate data in reversible steps and keep the old path available until the new one has earned trust.
- Measure error rates, latency, and business metrics per slice before expanding.
- Decommission deliberately; leaving both paths alive indefinitely is how modernization stalls.
How to de-risk a rewrite if you proceed
- Write a parity checklist from real user journeys, support tickets, and integration contracts.
- Freeze scope to parity first; enhancements come after cutover.
- Use shadow traffic or a pilot cohort before a full switch.
- Rehearse data migration repeatedly, including rollback.
- Define the rollback plan before launch, not during the incident.
- Track lead time, change failure rate, incident rate, and infrastructure cost so the outcome is measurable.
Modernization is not a technical event. It is a sequence of business decisions about risk, sequencing, and what the organization can sustain. The engineering approach should follow those decisions, not replace them.
Frequently asked questions
Is a rewrite ever the right call?
Yes. When the platform is unsupported, the architecture blocks a valuable requirement, or the cost of every change is higher than replacement, a rewrite can be rational. The case should be tied to business constraints and a bounded scope, not code aesthetics.
Can we refactor a system that has no tests?
Yes, but start by adding characterization tests around the behaviour you are about to change. Without a way to detect regressions, refactoring becomes a rewrite with extra steps.
How do we measure whether modernization worked?
Compare delivery lead time, change failure rate, incident frequency, infrastructure cost, and the ability to ship specific features before and after. If those do not improve, the rewrite did not solve the actual problem.
Further reading
Related service
Custom Software DevelopmentWritten by
Atsol Engineering
Atsol Engineering is the editorial team at Atsol Inc., an international software, AI, and engineering studio.
About Atsol



