# Rewrite vs Refactor: The Four Real Options | gen2.dev

> Rewrite vs refactor is the wrong question. There are four options for an aging system, and a short list of facts that tells you which one fits.

Source: https://gen2.dev/guide/rewrite-vs-refactor/

---

Field Guide

# Rewrite vs refactor: the four real options

The argument is usually framed as two choices. There are four, and the two that get left out are the ones that are right most often.

![Slide: four options around your system: leave it alone, refactor in place, replace it piece by piece, rewrite it.](https://gen2.dev/img/rewrite-vs-refactor.png)

Somebody on the team has said "we should just rewrite it." Somebody else has replied "you never rewrite." Both are repeating a slogan. Neither has looked at the system.

The honest version of this decision has four possible answers:

Option

What you do

When it fits

Leave it alone

Nothing, on purpose

The system is old but not failing

Refactor in place

Improve the running system behind tests

The problems are in the code, not the foundations

Replace it piece by piece

Build Gen 2 around Gen 1 and move one slice at a time

It must be replaced, and it is too big or too busy to replace at once

Rewrite it

Build a new system, then cut over

It is small, understood, and the business can wait

The rest of this page is how to tell which one you are looking at. If you would rather answer questions than read, the [Should we rewrite it?](https://gen2.dev/should-we-rewrite/) tool walks through the same ground in sixteen of them.

## Why the instinct to rewrite is so strong

In 2000 Joel Spolsky called rewriting from scratch "the single worst strategic mistake that any software company can make." His explanation of why engineers want to do it anyway has aged better than almost anything else written about software: it is harder to read code than to write it.

Old code looks worse than it is. The odd conditionals and special cases that make it ugly are, mostly, bug fixes. Each one is a thing that went wrong in production and was learned the hard way. A rewrite throws that knowledge out and schedules the team to learn it again.

There is a second force, and it is older. In 1975 Fred Brooks described the second-system effect: a small, successful first system tends to be followed by a successor that is over-engineered and bloated, because everything left out of the first one gets added to the second. A Gen 2 project is, almost by definition, a second system.

Neither of these means a rewrite is always wrong. They mean the desire to rewrite is not evidence that you should.

## Leave it alone

This is the option nobody proposes in a planning meeting, and it is correct more often than any of the others.

A system qualifies if all of these are true:

-   It runs on a platform that is still supported.
-   Changes to it are rare, or cheap enough.
-   Nothing bad happens if it looks exactly like this in two years.

"The code is embarrassing" is not on that list. Neither is "nobody wants to work on it." Those are real costs, but they are small and steady. A replacement project is a large cost paid up front against a benefit that arrives only if the project finishes.

Leaving a system alone is a decision, so write it down: what would have to change for the answer to change? A vendor end-of-life date. A customer you cannot serve. A compliance requirement. Then check that list once a year.

## Refactor in place

Choose this when the problems you can name are problems in the code: changes take too long, the same bug comes back, one module frightens everyone. The data model is basically right, the platform has a future, and there are people on the team who understand how it works.

What you need:

-   **Tests you trust,** or the patience to write characterization tests before you touch anything.
-   **People who know the system.** That knowledge is the asset. A rewrite throws it away; a refactor spends it.
-   **Permission to ship continuously.** Refactoring happens in the running system, next to feature work, in small steps.

Refactoring is also the right first move when you want to replace a system but cannot find anywhere to start. If everything talks to everything, there is no slice to move. Refactoring is how you create the seams that replacement needs.

## Replace it piece by piece

Choose this when the system really does have to go: the platform is dying, the model is wrong for the business, or the limits are measured and real. But it is too large, too poorly understood or too busy to replace in one move.

You put a routing layer in front of the old system, build a small piece of the new one, and send that one slice of traffic to it. Then you do it again. The old system shrinks until there is nothing left to switch off. This is the [strangler fig pattern](https://gen2.dev/guide/strangler-fig/), and it is how the replacements that finish tend to be done.

It costs more per month than a rewrite, because you are running two systems. It costs far less in total, because every slice ships, every slice can be rolled back, and the project can be stopped at any point with something to show for it.

The [Firefox Quantum case file](https://gen2.dev/cases/firefox-quantum/) is this approach applied to a browser engine that people were using every day while it was being replaced.

## Rewrite it

A clean rewrite is defensible when every one of these holds:

-   **It is small.** One team could rebuild it in about a quarter. Estimates beyond that tend to double.
-   **Its behavior is known.** There is a specification the business agrees with, or the system is simple enough that the code is readable as one.
-   **Gen 1 can be frozen.** No new features go into the old system while the new one is built. If that promise cannot be kept, the rewrite is chasing a moving target.
-   **You can go back.** Cutover is rehearsed and reversible.
-   **Nobody else's code depends on its quirks.** Plugins, integrations and API clients do not migrate on your schedule.

Then hold the scope still. Gen 2 does what Gen 1 does. Every improvement that is "easy to add while we are in there" is the second-system effect arriving one reasonable request at a time.

The [Netscape case file](https://gen2.dev/cases/netscape-6/) is what happens when a company bets everything on this option and most of that list is false.

## The six facts that decide it

![Slide: six numbered questions: is the platform supported, can the old system be frozen, how long would a rebuild take, is the data model wrong, is there somewhere to put a router, what does doing nothing cost.](https://gen2.dev/img/six-facts.png)

When the conversation goes in circles, bring it back to these. They carry most of the weight.

1.  **Is the platform still supported?** A dead platform turns "should we" into "when."
2.  **Can the old system be frozen?** If not, a from-scratch rewrite is off the table.
3.  **How long would a rebuild take?** Under a quarter and over a year are different decisions.
4.  **Is the data model wrong, or just the code?** Code can be refactored. A wrong model has to be replaced.
5.  **Is there somewhere to put a router?** If so, you can replace incrementally. If not, make one.
6.  **What does doing nothing cost?** If the answer is "not much," you are done.

## What a bad decision looks like

Three patterns come up again and again:

-   **The rewrite as morale project.** The team is tired of the code, and a new stack feels like a fresh start. Eighteen months later there are two systems nobody likes.
-   **The rewrite as reorganization.** New leadership wants a platform with its own name on it. The requirements are whatever the old system did not do, which is to say everything.
-   **The refactor that never ends.** Nobody defined what done looks like, so the cleanup becomes a permanent tax with no result anyone can point to.

Each one skips the same step: saying, in a sentence, what is wrong with the system today and how anyone will know when it has been fixed.

## When not to use it

Choosing among four options assumes there is a problem to solve.

-   **The system works and changes rarely.** Leaving it alone needs no analysis beyond security fixes.
-   **The product itself is being replaced or dropped.** Decide that first.
-   **A tool or vendor deadline already decides it.** Spend the time on the migration, not the debate.

## Common questions

### Should we rewrite it or refactor it?

Those are two of four options. You can leave the system alone, refactor it in place, replace it piece by piece, or rewrite it. The two that get left out of the argument, leaving it alone and replacing it piece by piece, are the ones that are right most often.

### When is a full rewrite the right call?

Only when the old system can be frozen while the new one is built. If it cannot be frozen, a from-scratch rewrite is off the table. A rewrite is easier to defend when the platform is no longer supported, when the data model itself is wrong, or when the rebuild would take less than a quarter.

### What if doing nothing costs very little?

Then you are done. If the honest answer to what doing nothing costs is not much, leave the system alone.

## Sources

1.  [Joel Spolsky - Things You Should Never Do, Part I (April 6, 2000)](https://www.joelonsoftware.com/2000/04/06/things-you-should-never-do-part-i/)
2.  [Second-system effect - Wikipedia](https://en.wikipedia.org/wiki/Second-system_effect) - Fred Brooks, The Mythical Man-Month (1975)
3.  [Martin Fowler - Strangler Fig](https://martinfowler.com/bliki/StranglerFigApplication.html)

Last updated November 29, 2026.

## Field Guide

-   [Rewrite vs refactor](https://gen2.dev/guide/rewrite-vs-refactor/)
-   [The 7 Rs](https://gen2.dev/guide/seven-rs/)
-   [Characterization tests](https://gen2.dev/guide/characterization-tests/)
-   [Estimating a rewrite](https://gen2.dev/guide/estimating-a-rewrite/)
-   [Strangler fig pattern](https://gen2.dev/guide/strangler-fig/)
-   [Monolith to microservices](https://gen2.dev/guide/monolith-to-microservices/)
-   [Lift and shift](https://gen2.dev/guide/lift-and-shift/)
-   [Second-system effect](https://gen2.dev/guide/second-system-effect/)
-   [Branch by abstraction](https://gen2.dev/guide/branch-by-abstraction/)
-   [Anti-corruption layer](https://gen2.dev/guide/anti-corruption-layer/)
-   [Parallel run](https://gen2.dev/guide/parallel-run/)
-   [Shadow traffic](https://gen2.dev/guide/shadow-traffic/)
-   [Dual write and data migration](https://gen2.dev/guide/dual-write/)
-   [Expand and contract](https://gen2.dev/guide/expand-and-contract/)
-   [Data migration tools](https://gen2.dev/guide/data-migration-tools/)
-   [The cutover](https://gen2.dev/guide/cutover/)
-   [Feature flags and dark launches](https://gen2.dev/guide/feature-flags-and-dark-launches/)
-   [Big-bang cutover](https://gen2.dev/guide/big-bang-cutover/)
-   [API versioning](https://gen2.dev/guide/api-versioning/)
-   [Running two systems](https://gen2.dev/guide/running-two-systems/)
-   [Killing Gen 1](https://gen2.dev/guide/killing-gen-1/)
-   [Rewriting a mobile app](https://gen2.dev/guide/rewriting-a-mobile-app/)
-   [Selling a rewrite](https://gen2.dev/guide/selling-a-rewrite/)
-   [AI-written code](https://gen2.dev/guide/ai-written-code/)

## Should we rewrite it?

Sixteen questions about your system. A recommendation, and the reasoning behind it.

[Start the questions](https://gen2.dev/should-we-rewrite/)
