Decide what you can replace while the business keeps running
A rewrite may look manageable with 12 or 18 months to build and a weekend to switch over. During that time, the old system still serves the business and its requirements can change. If an important rule is missing, the new system can cause problems even when it implements everything in the original feature list.
In Patterns of Legacy Displacement, Ian Cartwright, Rob Horn and James Lewis describe how a goal of full feature parity pushed projects toward one complex cutover. Working out which behavior to preserve was itself a substantial task.
Martin Fowler's Strangler Fig pattern takes its name from a fig that grows around a host tree and eventually stands on its own. Introduce a replacement alongside the old system. Move one function, confirm that users and dependent systems can rely on the new version, and retire the old function only when its dependencies are accounted for.
Map what actually depends on the system
List what happens behind the screens: scheduled jobs, reports, exports, spreadsheet macros that read the database, and manual steps that staff use to get their work done. Each dependency needs to move, continue using the old system for an agreed period, or be deliberately retired.
In one case described by the Thoughtworks authors, reports missed products. The team traced the problem to a replicated middleware database that fed batch jobs and data warehouse views. The replica had been left out of the integration inventory. Reports continued to need that data.
Interview staff, then verify their accounts against the system.
- Database access. Record stored procedures, triggers, views and database accounts. Identify the person, service or job that uses each account.
- Scheduled work. List cron jobs, Windows Task Scheduler entries, SQL Agent jobs and application jobs. Record what each one writes and who reads it.
- Interfaces. Include files, email imports, API calls and queues in both directions.
- Reports and exports. Identify who uses each output and the decision it supports. Unused reports can be candidates for retirement.
- Business rules. Record rules such as discounts, approval limits and rounding for applicable taxes. Name the person who can confirm each rule.
Give the business a dependency map showing components, data stores, consumers and the work they support. Update the map as each function moves.
Choose how to handle each component
AWS describes seven migration strategies: retire, retain, rehost, relocate, repurchase, replatform, and refactor or re-architect. It describes refactoring as the most complex and costly of the seven. For a large migration, it recommends moving workloads first and modernizing later where practical. You can use these choices to plan mixed outcomes for different parts of a business system.
| Path | What happens | Example |
|---|---|---|
| Retire | Decommission it and archive the required data | A report nobody has used in a year |
| Retain | Keep it in service and maintain its connections | A payroll module that meets current needs |
| Rehost, relocate or replatform | Move with limited changes to the application | Move a supported database to a managed service |
| Repurchase | Replace it with an existing product | Move from a custom CRM module to a hosted CRM |
| Refactor or re-architect | Change the design or rebuild the component | Redesign an order and pricing engine whose limits prevent growth |
Review what a component does, who depends on it, and the cost and risk of keeping or replacing it. Redesign where the existing component cannot support the required change. Check contracts and retention rules before retiring anything.
Route requests through a façade
Microsoft's Strangler Fig guidance describes a façade that receives requests and directs each one to the old system or its replacement. At first, almost everything goes to the old system. As functions move, the façade routes more calls to the new system. Clients can keep using the same entry point while this happens.
Four phases of migration using Strangler Fig
- Add a façadeRoute requests through a shared entry point while the old system still serves most of them
- Move functionsRoute each migrated function to the new system, with other functions still served by the old one
- Retire the old systemConfirm that no required dependencies remain before decommissioning and archiving data
- Remove or keep the façadeSend clients directly to the new system or keep the façade as an adapter where needed
A reverse proxy or API gateway can route web traffic by path. If a desktop client connects directly to a database, you might need a database integration point or a service in front of it. Check that you can intercept the requests and redirect calls from the old system as needed. If the source cannot be changed and there is no suitable integration point, the pattern may not fit. A small system that can be replaced in one step, or a system that must be retired quickly, may also call for a different approach.
Budget for running and monitoring the façade. Check its capacity and what happens if it fails, so it does not become a bottleneck or a single point of failure. Decide whether clients will still need the old interface after migration.
Set rules for data shared by old and new functions
Decide which system is authoritative and which can write each record in each phase. Both systems may need the same customers, products or orders. An anti-corruption layer is an adapter that translates between their models. It lets the new system use its own field names and rules while supporting calls to and from the legacy system.
Microsoft illustrates this with a shared database that is split by domain. The new service initially uses the legacy database. Then an extract, transform and load process (ETL) loads historical data into a new domain database, while change data capture (CDC) synchronizes continuing changes. Validate consistency before making the new database authoritative. The example includes writes to both environments during the transition. Specify how concurrent writes are handled and test the design you use.
As Microsoft notes, returning to the old database is possible while the relevant objects and synchronization remain. After removal, recovery can require restoring those objects and replaying changes. Keep rollback conditions, write ownership and retirement decisions explicit. See the data migration guide for mapping, validation and reconciliation.
Record existing behavior before replacing it
Michael Feathers describes characterization tests in Working Effectively with Legacy Code. They record what the system does today so the team can compare the replacement with it. The owner still needs to decide which behavior to keep.
For example, use 200 representative orders from the previous quarter that you are authorized to test. Remove unnecessary personal details. Record the old pricing results, run the same cases through the new service and compare each line. Ask the business owner to identify defects, behavior to preserve and differences that still need investigation. Record the agreed outcome for each case.
Include closing periods, returns, partial deliveries, zero-value lines, orders in different currencies and records from before a rule change. Test rare cases if they affect money, stock or reporting.
Run both implementations on the same transactions
Characterization tests use a fixed sample. In a parallel run, both systems process input from the same live transactions while the legacy system remains authoritative. Keep the comparison system from charging customers, sending duplicate messages or posting stock changes. Reconcile the outputs daily. The Thoughtworks authors also describe dark launching, where the new service is called but its result does not drive the workflow.
Agree in advance which outputs to compare, the acceptable tolerance for each, and when the run can finish. For example, compare invoice totals, tax, stock movements and approval decisions. Require exact agreement for invoice totals where appropriate, and agree rounding tolerances for conversions. One possible exit rule is ten consecutive business days with no unexplained differences, including one period-end close when that close matters.
Is a function ready to switch over?
What did the parallel run show?
- No unexplained differences through the agreed period, including the relevant closeSchedule the cutover and agree the rollback window
- The business owner has confirmed that the differences correct defects in the old systemRecord the decisions and schedule the cutover
- Unexplained differences remainInvestigate before making the new system authoritative
- Recurring differences affect money, tax or stockPause the run, correct the cause and run it again
Switch one function at a time and test recovery
For each function, document when routing changes, who watches the first hours, which reconciliations run immediately and when traffic should return to the old system. Test whether changing the route restores the service. If the new system has accepted writes, define how to replay or reconcile those transactions before handing control back.
Keep the old component available, read-only where possible, until the rollback window closes. Before retirement, archive required data, set the retention period, remove unused credentials and jobs, and update the dependency map. Confirm retirement with the business owner and record any dependency that needs both systems for longer.
Use AI coding tools for work that can be checked
AI coding tools can help read unfamiliar code, summarize procedures, draft dependency notes, suggest tests and translate routine code. Ask business owners whether an unusual rounding rule comes from an applicable requirement, a customer agreement or an old error. A tool may preserve a defect or omit a hidden rule, so review generated changes and run the same tests and reconciliation. Check data-handling rules before sharing code or data with a service outside your environment.
Ask the modernization partner how each function will move
Questions for a modernization proposal
- First functionWhich function goes first, why, and what will the business gain?
- RoutingWhere will the façade sit and what happens if it fails?
- Shared recordsWhich system owns each record in each phase, and how are changes synchronized?
- EvidenceWhich characterization tests and reconciliation records will show that the function is ready?
- RecoveryHow can the team roll back, and until when?
- RetirementWhen can each old component be removed, and who agrees?
If you are still deciding whether to replace the system, compare building, buying and extending software. Our legacy modernization and data migration service starts with a dependency map and a staged plan. Use the contact page to describe your system.
Questions buyers ask
How long does a Strangler Fig migration take?
It depends on the number of functions, dependencies and shared data. The first slice can take longer because the team also sets up routing, tests and reconciliation. Later slices can reuse this work. Plan and fund the work in stages, using what the first slice reveals to refine the schedule.
When is replacing the whole system at once reasonable?
Consider it when the system is small, its behavior is well understood, or it must be taken out of service quickly. Verify that the team can migrate the data, test important workflows and recover from a failed cutover in the time available. One cutover for a large system puts more changes into the same window.
What if we cannot change the legacy source code?
Check for an integration point you can control, such as a request route, database interface or file exchange. If you cannot intercept the requests or redirect the relevant dependencies, the pattern may be unsuitable. Consider a replacement with a planned data migration.
Can AI tools rewrite legacy code for us?
They can help explain unfamiliar code, draft notes and tests, or translate routine code. Have the business confirm what behavior matters. Review and test changes and reconcile outputs with the same care as for code written by hand.