Written by Gowtham Raj, Director at TartLabs, who leads custom software and modernization engagements for manufacturing, logistics, and enterprise clients.
The Short Answer
Refactor in slices by default, replace with a product when the system is not a differentiator, and rewrite from scratch only for a small, well-understood component. AI has made the first option cheaper, because it speeds up reading code and making repetitive changes. It has not made a full rewrite safer, because the hard part of a rewrite is knowing what the old system really does, and that has to be settled by people and tests.
Key Takeaways
- Refactoring in slices is the default because the old system keeps running while the new one grows beside it.
- AI lowers the cost of refactoring. Google's engineers estimated about 50% less total time on 39 scoped migrations, with 74.45% of code changes generated by the model.
- A rewrite still carries its old risk. Joel Spolsky called it the worst strategic mistake a software company can make in 2000, and Martin Fowler says the simple plan of building an exact replacement has usually gone down in flames.
- Replacing with a product is a business decision, not a technical one. It suits systems that do not set you apart from competitors.
- Gartner, as reported by The Register, expects more than 70% of mainframe exit projects started in 2026 to miss their intended benefits, mainly because GenAI is overestimated.
The Options, Named Properly
People use "rewrite", "refactor" and "replace" loosely, so it helps to pin them down. AWS's migration guidance lists seven strategies: retire, retain, rehost, relocate, repurchase, replatform, and refactor or re-architect. They map onto the three words in the title like this.
| Your word | AWS term | What changes | What stays |
|---|---|---|---|
| Keep it running | Retain, rehost | Where it runs | The code |
| Refactor | Replatform, refactor or re-architect | Structure, and sometimes the platform | The behaviour |
| Replace | Repurchase | The whole application, for a vendor product | Your data, moved across |
| Rewrite | Not a listed strategy | The code and the design | Only what you can specify |
| Switch it off | Retire | Nothing, the system is decommissioned |




