Engineering Partnerships

Legacy Software Modernisation: Rewrite, Refactor or Replace?

How to modernise an old but valuable system without a risky big-bang rewrite.

4 min read

Old desktop computer on a desk
Photo: Dan Counsell on Unsplash

In short

  • Legacy software modernisation has more options than “rewrite everything”: retire, retain, rehost, relocate, replatform, refactor or replace (the “7 Rs” used by AWS).
  • Full rewrites are the riskiest path. Most successful programs replace a system piece by piece while it keeps running (the strangler fig pattern).
  • AI coding tools now speed up code understanding and migration, but they do not remove the need for tests, clear boundaries and business ownership.

Legacy software modernisation is one of the hardest decisions in technology leadership. The old system works, earns money and holds years of business rules nobody fully remembers. It is also slow to change, expensive to run, and increasingly hard to staff. This guide explains the main options, when each one fits, and how to modernise without betting the business on a single big-bang release.

The options: the 7 Rs

AWS describes seven strategies for moving applications, known as the 7 Rs (AWS). They evolved from a five-option framework Gartner introduced in 2010 (IBM). They work well beyond cloud moves, as a vocabulary for any modernisation decision:

OptionWhat it meansWhen it fits
RetireSwitch it offLittle or no business value left
RetainKeep it as is, for nowWorks fine, low change rate, other priorities first
RehostMove it unchanged to new infrastructure (“lift and shift”)Data centre exit, quick cost wins
RelocateMove at the platform level without changesVirtualised workloads moving between environments
ReplatformSmall changes to use managed servicesReduce operations work without a rewrite
Refactor / re-architectChange the code and architectureThe system is core to the business and must evolve fast
Repurchase (replace)Switch to a commercial product or SaaSThe function is not a differentiator

AWS notes that refactoring is the most complex strategy and not recommended for large migrations done all at once (AWS). That matches what we see: the more you change at once, the more can go wrong.

Rewrite, refactor or replace?

  • Replace when the system does something many products already do well (HR, accounting, standard CRM). Your energy is better spent elsewhere.
  • Refactor incrementally when the system holds your competitive logic. Improve structure and tests while keeping it in production.
  • Rewrite only when the technology is truly dead, the scope is small enough to finish quickly, or the business model changed so much that old rules no longer apply. Even then, rewrite in slices.

Legacy software modernisation, step by step

  1. Map the system and its value. Which modules earn money, change often, break often or block new features? Modernise those first.
  2. Build a safety net. Add characterisation tests that capture current behaviour, including the strange parts. Record real traffic for replay where possible.
  3. Find seams. Identify boundaries where a new component can take over one capability. See microservices vs modular monolith for how far to split.
  4. Strangle gradually. Route one capability at a time to the new implementation, keeping the old one as fallback: the strangler fig pattern (Martin Fowler).
  5. Move data carefully. Use change data capture or dual writes with reconciliation; never assume a one-night migration will just work.
  6. Measure and retire. Track error rates, performance and cost; switch off old parts as soon as traffic has moved.

Where AI helps, and where it does not

AI coding assistants are good at explaining unfamiliar code, generating tests around existing behaviour and translating routine code between languages. Vendors are building on this: in September 2026 Thought Machine and AWS announced an AI-powered approach to extract business logic from legacy banking systems as a path from mainframe code to cloud-native core banking (Amazon). What AI does not do is decide which business rules still matter, own the risk of a cutover, or replace tests as proof that behaviour is preserved. Read What is AI-native software development? for how we use these tools safely.

From our work

Three in four of our new projects come from recommendations, typical engagements last more than three years, and on one automotive programme we met 6 of 6 hard deadlines. We are a nearshore software development partner in Romania with senior engineers for fintech, mobile and automotive HMI and robotics products.

Technologies you will meet

AreaTypical tools
Legacy stacksCOBOL on mainframes, older Java EE, .NET Framework, PHP, Delphi, Oracle Forms
Target stacksJava or Kotlin with Spring Boot, .NET 8+, Go, Node.js, PostgreSQL, Kubernetes
Migration patternsAPI gateways for routing, Debezium for change data capture, Kafka for events
Safety netCharacterisation tests, contract tests (Pact), traffic replay, feature flags
Code understandingAI coding assistants (Claude Code, GitHub Copilot, Cursor), static analysis, dependency graphs
CloudAWS, Azure, Google Cloud, Terraform, managed databases

Modernisation programs fail more often on planning and estimates than on technology. Before you start, read how to brief a software partner for an accurate estimate and what technical due diligence checks; if the program is already behind, how to rescue a late software project.

Frequently asked questions

What are the 7 Rs of modernisation?

Retire, retain, rehost, relocate, replatform, refactor and repurchase, as described by AWS.

Should we rewrite our legacy system?

Rarely all at once. Incremental refactoring or replacement piece by piece is usually safer.

What is the strangler fig pattern?

Gradually routing capabilities from the old system to new components until the old system can be switched off.

Can AI tools modernise legacy code?

They speed up understanding, test writing and routine translation, but people must decide business rules and own the cutover.

Working on something like this?

Tell us where the product is stuck. We answer with a concrete next step.

Send a few lines about the product, the deadline and the team you have today. A senior engineer replies within two working days.