Skip to content
Proudly Canadian, serving Windsor to Toronto, Ontario · clients welcome from every countryContact usClient login
CodeLumaDevelopment Inc.

Home / Blog / Article

CodeLuma insights · April 1, 2026 · 5 min read

When to Rewrite vs. Refactor: Making the Right Call for Your Growing App

Rewrites are tempting and dangerous. Here is a practical framework for deciding whether to refactor, strangle, or rewrite an application, with warning signs, costs and a safe migration path.

Every growing application eventually reaches the point where someone says, "we should just rewrite it." The idea is seductive: no more legacy quirks, a modern stack, and a clean slate. It is also one of the most expensive mistakes a software business can make. Rewrites take longer than planned, they freeze feature work, and they often recreate the same problems in new code. On the other hand, some systems genuinely cannot be saved. This guide gives you a practical framework for telling the difference.

Four options for an ageing application: refactor, strangle, rewrite, or leave it alone.
Four options for an ageing application: refactor, strangle, rewrite, or leave it alone.

Why rewrites so often go wrong

An old system encodes years of decisions, edge cases and customer-specific behaviour that nobody wrote down. When a team rewrites from scratch, it rediscovers those rules one production bug at a time. Meanwhile the business is still running on the old system, so changes must be made twice, or the old system stagnates while the new one is unfinished. The classic failure pattern is a "second-system" project that runs a year over schedule, launches with fewer features than the original, and leaves customers unhappy.

That does not mean rewrites are never right. It means the burden of proof is high, and the alternatives deserve a serious look first.

A laptop showing source code on a desk
Original CodeLuma 3D render: a laptop showing source code on a desk.

First, diagnose what is actually wrong

"The code is bad" is not a diagnosis. Before choosing a strategy, identify the specific pain:

  • Speed of change: how long does a small feature take from request to release, and is that getting worse?
  • Reliability: how often do releases cause incidents, and how long do they take to fix?
  • Performance: are slow pages caused by design, queries, infrastructure, or a few hot spots?
  • Security posture: are there unfixable design issues, or outdated dependencies that can be upgraded?
  • Hiring and knowledge: can you find developers for the stack, and does anyone understand the whole system?
  • Cost to operate: hosting, licences, and manual workarounds staff perform every day.

Measure these where you can. A short technical audit, including dependency review, test coverage, static analysis, database review, and a look at deployment practice, usually reveals that a large share of the pain comes from a small number of problem areas.

The refactor path

Refactoring means improving the internal structure without changing behaviour. It is the right choice when the overall design is sound but the code has grown untidy. Effective refactoring is disciplined:

  1. Add characterisation tests around the behaviour you must not break, even if they are crude end-to-end checks.
  2. Refactor in small, releasable steps, shipping continuously rather than in a giant branch.
  3. Attack hot spots first: the files that change most and cause the most bugs.
  4. Upgrade dependencies and runtimes incrementally so security patches stay available.
  5. Improve observability with logging, error tracking and metrics so problems become visible.

Refactoring rarely feels dramatic, but it keeps revenue flowing and reduces risk with every release.

The strangler path

When a system is too large or too tangled to refactor in place, but a big-bang rewrite is too risky, the strangler pattern is often the best compromise. You place a routing layer in front of the old system, build one capability at a time in a new module or service, and redirect traffic for that capability once it is proven. Over months, the old system shrinks until it can be retired. Each step is small, reversible and measurable. Good candidates for early extraction are self-contained areas such as authentication, reporting, notifications, or a public API.

Warning signs that a full rewrite might be justified. One sign alone rarely is enough.
Warning signs that a full rewrite might be justified. One sign alone rarely is enough.

When a rewrite is justified

A rewrite makes sense when most of the following are true: the platform is genuinely unsupported and cannot be upgraded; core design assumptions, such as the data model or single-tenant architecture, block the business model; test coverage is nonexistent and cannot be added economically; security problems are structural; and the organisation can fund a parallel build and freeze scope. Even then, run it as a phased migration: define the smallest slice that delivers value, migrate customers in cohorts, and keep the old system available as a fallback.

A notebook with wireframe sketches
Original CodeLuma 3D render: a notebook with wireframe sketches.

How to run a rewrite safely if you must

  • Document current behaviour before building: workflows, integrations, reports, scheduled jobs, and the unofficial spreadsheets people rely on.
  • Keep scope disciplined. "Feature parity plus improvements" is how projects double in size. Ship parity first.
  • Migrate data early and repeatedly. Rehearse the migration many times so cutover is boring.
  • Run both systems in parallel for a period and compare outputs.
  • Define a rollback plan and a go-live checklist with clear ownership.

Estimate honestly

Whatever you choose, get a range, not a single number, and ask what assumptions drive the top of the range. Include data migration, integrations, training, and the time your own team will spend answering questions. If a vendor promises a full rewrite in a fraction of the original development time without a discovery phase, treat that as a red flag.

A simple decision rule

If the design works and the code is messy, refactor. If the system is large and the risk of replacement is high, strangle it. If the platform is dead and the design blocks the business, plan a phased rewrite. If it is stable and not blocking growth, leave it alone and invest elsewhere. A structured audit turns that judgement from opinion into evidence, and it is usually the cheapest step you can take before committing hundreds of thousands of dollars to a direction.


Put this into practice with CodeLuma

CodeLuma audits existing applications and recommends the least risky path, whether that is targeted refactoring, an incremental replacement, or a full rebuild, with a clear cost and timeline before you commit.

Start a conversation. Tell us about your project and we will reply with practical next steps, or browse all CodeLuma services. CodeLuma Development Inc. is a Canadian company that works with teams in Windsor, Essex, London, Toronto, Mississauga and across Ontario, throughout Canada and remotely.

Keep reading

Share this article: Facebook · LinkedIn · X · Email

← All articles

Ready to put this into practice?

Talk to a Canadian full-stack team that builds complex, connected systems for clients across Canada and worldwide.

Start a project