Back to all posts
Architecture7 min read·October 25, 2026

Rewrite vs Refactor: How to Decide for Legacy Software

TB
ThynkBlox Team
Engineering

Should you rewrite or refactor legacy software?

In the rewrite vs refactor decision, favour refactoring when you can improve the existing software while preserving the behaviour users depend on. Consider a rewrite when specific foundations prevent essential changes and improving them in place is impractical. Where replacement is justified, assess whether you can replace one capability at a time instead of switching the entire product at once.

Start with the business obstacle: an unreliable checkout, changes that take too long, or a dependency you can no longer maintain safely. “The code is old” does not define a problem worth rebuilding a product to solve.

What is the difference between rewriting and refactoring?

Refactoring changes the internal structure of software while preserving its observable behaviour. Examples include separating a large function into smaller parts or removing duplicated rules without changing their results.

Rewriting creates a replacement implementation for an existing capability. It may preserve the current user experience, introduce new behaviour, or do both.

These choices do not have to apply to the whole application. You might refactor order processing, replace reporting, and leave account management alone.

Keep behaviour changes separate from structural changes where practical. If you change both together, define which differences are intentional so reviewers can distinguish improvements from defects.

For the broader business context, read technical debt explained for founders.

What signals favour refactoring?

Favour refactoring when the product still fits the business and the main obstacles have identifiable boundaries.

Look for evidence such as:

  • Useful foundations. The existing data model and application structure can support the required changes.
  • Concentrated friction. Recent delays trace back to particular modules, duplicated rules, or unclear responsibilities.
  • Verifiable behaviour. You can establish expected results through tests, documented examples, or observed workflows.
  • Independent improvements. A small structural change can be released without rebuilding neighbouring features.

For example, if several screens calculate the same delivery charge differently, consider consolidating that rule and testing its outcomes. Replacing unrelated screens would need a separate justification.

Do not require a perfect test suite before starting. Identify the behaviour affected by the proposed change and establish checks for that scope. Our guide to software testing and quality assurance provides related background.

What signals favour a rewrite?

Consider replacement when you can name the constraint that refactoring would leave unresolved.

Possible signals include:

  • An unsuitable data model. Essential business relationships cannot be represented correctly without changing the foundation.
  • An unmaintainable dependency. You have verified that a critical dependency lacks a viable maintenance or upgrade path.
  • A sharply changed purpose. The required product serves workflows that differ substantially from those the current system supports.
  • A bounded capability with a clear contract. You can describe its inputs, outputs, permissions, and failure behaviour well enough to build a replacement.

Treat these as investigation prompts, not automatic approval.

Ask for a concrete explanation of why an in-place change is impractical. A preference for another programming language is insufficient. So is a demonstration that the new implementation looks cleaner before it handles the existing product’s difficult cases.

How can you compare the options?

Use this table to frame the decision. Record evidence beside each relevant row rather than counting ticks.

Decision factorFavour refactoring when…Consider replacement when…
Business behaviourCurrent workflows remain usefulRequired workflows need fundamentally different behaviour
Problem scopeObstacles are local and separableA defined capability has unsuitable foundations
DataExisting relationships remain validRequired relationships need a different model
DependenciesA supported upgrade path is practicalNo viable path exists for a critical dependency
VerificationExisting behaviour can be checked during small changesA replacement has explicit acceptance criteria
TransitionImprovements can ship independentlyUsers and data can move through a controlled transition
InvestmentSmaller changes remove the important constraintsReplacement has a justified cost and retirement plan

If neither column fits clearly, choose a bounded investigation. Trace a representative change, inspect its dependencies, and test the hardest assumption before committing to a larger programme.

What is the strangler approach?

The strangler approach replaces an existing system gradually. Selected requests or workflows move to a new implementation while the remaining capabilities continue using the old one. As replacement proceeds, the old system’s responsibilities shrink.

A practical sequence is:

  1. Choose a capability with a boundary you can describe.
  2. Define the behaviour the replacement must preserve.
  3. Decide where requests will be directed to the old or new implementation.
  4. Assign ownership of the affected data.
  5. Move a controlled set of users or workflows.
  6. Check results and failures before expanding.
  7. Retire the old capability once its remaining dependencies are removed.

The difficult part deserves attention before construction: coexistence.

If both systems can edit the same record, define how conflicting updates are handled. Prefer clear ownership over an unexplained promise to “keep everything in sync”.

Also define rollback. Sending requests back to the old system is insufficient if it cannot understand data written by the replacement.

What could gradual replacement look like?

Consider an illustrative order-management product whose reporting feature delays requested changes. Order entry still meets the business’s needs.

Instead of rebuilding the product, propose a reporting replacement with a defined set of reports and access rules. Keep order entry as the owner of order records, and specify how reporting receives updates and communicates their freshness.

Compare the replacement’s results against agreed examples, including cancelled orders, refunds, and restricted accounts. Investigate differences before moving users.

After the new reports meet acceptance criteria, redirect reporting requests. Remove the old reporting code only after checking scheduled exports and other consumers.

This example illustrates a boundary to investigate. It does not establish that reporting is always an easy starting point.

What are the risks of a big-bang rewrite?

A big-bang rewrite replaces the whole system at a single cutover. Before choosing it, address these risks explicitly.

Missing behaviour. Requirements gathered from visible screens may omit background jobs, exceptional cases, and integrations. Include these in the replacement’s acceptance criteria.

A moving target. If the current product continues changing, decide which changes the replacement must reproduce and who funds that work.

Data cutover. Specify how records, relationships, and updates made during migration will reach the new system. Rehearse the transition with representative data.

Concentrated launch exposure. A single switch places many changed workflows into use together. Define failure detection, support arrangements, and recovery conditions.

Delayed retirement. Budget for both systems until the old one can actually be switched off. Include remaining integrations and data-retention obligations in that definition.

For a small, bounded application, a single replacement may be reasonable. The decision should follow demonstrated transition feasibility.

What common mistakes should you avoid?

Rebuilding every existing feature. Confirm which capabilities users still need before recreating them.

Changing architecture without a business reason. Neither a different language nor a different deployment structure is an outcome by itself. Tie the choice to a concrete requirement. See microservices vs monolithic architecture for a related comparison.

Using refactoring to expand scope silently. New pricing rules or changed permissions need explicit acceptance criteria.

Leaving gradual replacement unfinished. Assign a retirement condition to each migrated capability. Otherwise, maintaining both implementations remains part of the product’s workload.

What should you decide before approving the work?

Ask for a proposal that answers:

  • Which business obstacle will this remove?
  • What evidence favours refactoring or replacement?
  • Which behaviour must remain unchanged?
  • What is the smallest useful scope?
  • How will data ownership, migration, and rollback work?
  • What result would stop or change the approach?
  • What proves the old capability can be retired?

Approve a defined outcome with a review point. For larger changes, make the next commitment depend on evidence from the first completed slice.

What else do founders ask about rewriting and refactoring?

Is refactoring always cheaper?

No. Compare the work needed to reach the same outcome, including verification, migration, coexistence, and retirement. The smaller initial estimate is not necessarily the smaller total commitment.

Can you refactor and rewrite together?

Yes. Refactoring may establish a boundary around a capability before you replace it. Keep each step’s purpose and acceptance criteria explicit.

Should you rewrite because the original developers have left?

That alone is insufficient. First assess whether the current team can understand, test, and maintain the software. Missing knowledge is also a problem for anyone building its replacement.

What if the product will be retired soon?

Compare the proposed investment with its remaining business purpose. A narrow maintenance change may be sufficient. Reassess if continued operation cannot meet essential requirements.

If the pressure comes from a framework that has lost support, read what to do when your software framework is unsupported.


*Need help deciding what your existing software needs? Start a conversation →*

Ready to build?

Let's turn these ideas into your next product.

Start your project