Skip to content
Dave Brown

Should we rewrite our software from scratch or refactor it?

Refactor in almost every case. A full rewrite is justified only when the underlying platform is unsupported, the architecture makes your core business goals impossible, or nobody can safely change the code. Rewrites usually take two to three times longer than estimated, and the old system has to keep running meanwhile. Replacing it piece by piece is safer.

Dave Brown · CTO & Executive Advisor · Updated

Developers ask for rewrites because working in messy code is unpleasant, and a clean slate is appealing. But the existing software contains years of decisions about edge cases, customer quirks, and bug fixes that nobody has written down. A rewrite throws that knowledge away and has to rediscover it.

Why are rewrites so risky?

Three things go wrong repeatedly:

  • Time. A rewrite is estimated against the visible features, while the hidden behavior takes the extra months.
  • Double running. You must keep fixing the old system while building the new one, so you pay for two teams' worth of work.
  • No new value. For 9 to 18 months customers see nothing new, while competitors keep shipping.

I have seen a rewrite succeed and I have seen it sink a team. The difference was never the technology. It was whether the scope was controlled and the old system was retired in steps.

When is a rewrite actually justified?

A rewrite makes sense when at least one of these is true:

  1. The platform is end-of-life. Examples are an unsupported language version, a framework that no longer gets security patches, or a vendor that has shut down.
  2. The architecture blocks the business. You need multi-tenant support, a new region, or real-time behavior that the current design cannot reach.
  3. The code is unsafe to change. Every release breaks something and nobody understands the core module.
  4. You cannot hire for the stack and cannot retain the people who know it.

Slow feature delivery, ugly code, or an unfashionable language on their own are not reasons. They are reasons to refactor.

What is the alternative to a big-bang rewrite?

Replace the system piece by piece. This is often called the strangler approach: put new code in front of the old system, move one capability at a time to the new design, and delete the old part once the new one is proven. The old system keeps earning money the whole time, and you can stop or change course at any point. At Expedia I ran four teams through a service-oriented rewrite of two monolithic applications, and that kind of work only stays survivable when it ships in pieces.

The steps look like this:

  1. Add tests around the behavior you care about, even crude ones.
  2. Pick the part that hurts most or changes most often.
  3. Build its replacement behind a switch and send a small share of traffic to it.
  4. Compare results, then move everything over and remove the old code.
  5. Repeat.

How do I decide?

QuestionPoints toward refactorPoints toward rewrite
Does the system make money today?Yes, reliablyIt barely works
Is the platform supported?YesNo, or being shut down
Can the team ship a small change safely?Slowly, but yesNo
Is the problem one module?YesEverywhere
Can we hire for the stack?YesNo

Count which column wins. If most answers sit in the left column, refactor.

What does each path cost?

A staged refactor typically takes 20 to 30 percent of engineering capacity for 6 to 18 months. A full rewrite of a mid-sized product (a team of 5 to 10 engineers for a year or more) often costs $500,000 to $2 million once you count the parallel maintenance. Get a written estimate with a time cap and a clear definition of done before agreeing to either.

What I'd do

Start with the strangler approach and refactor the worst module first. Prove it improves delivery speed within a quarter. If after that you still find a hard blocker, such as a dead platform, make the case for a rewrite with numbers and a staged plan, not a feeling.

Where I come in. If this is a decision in front of you right now, it’s the kind of thing I help with through Technical Strategy. A focused engagement scoped to the decision at hand — typically a few weeks of working sessions and review.

Get in touch

Available for a small number of conversations.

If something here is relevant to a decision you’re facing, I’d like to hear about it.