← Tous les articles

Rewrite Your Application from Scratch or Evolve It? How to Decide Without Putting the Business at Risk

An ageing application, a new agency suggesting you start over, features that take longer and longer to ship: how to tell whether to rewrite or modernise step by step, and how to manage the transition.

Rewrite Your Application from Scratch or Evolve It? How to Decide Without Putting the Business at Risk

Key points

  • A full rewrite is rarely the right first move: it freezes the product and quietly drops business rules nobody ever wrote down.
  • It is justified in specific cases: a dead-end technology, an architecture that contradicts what you need, code that can’t be reliably deployed or tested.
  • Most of the time, incremental modernisation, one module at a time behind the same URL, delivers sooner and with far less risk.

“We should just rebuild it.” If your business runs on an in-house application, a SaaS product or a back office built a few years ago, you’ve probably heard that sentence, from a developer, a new agency or your own team. Sometimes it’s right. Often it’s said too quickly. On the projects we take over, we see both: applications that genuinely needed a rewrite, and many more where gradual modernisation fixed the real problems with no downtime and no big-bang launch. This guide gives you the criteria to decide, the hidden costs to plan for, and a practical method for evolving an application without stopping the business.

Why rewriting is so tempting (and what that hides)

Old code is always harder to read than code you write yourself. That applies to every developer, including when they look at their own work from three years ago. What looks “badly done” is sometimes just written with the tools and conventions of its time, or loaded with edge cases that each exist for a reason. Before concluding that an application is beyond saving, separate three situations that are easily confused:

  • the code is unpleasant to read: inconsistent naming, huge files, mixed styles. Annoying, but it can be cleaned up gradually, change by change;
  • the code is dangerous to change: every fix breaks something else, some files nobody dares to touch, no tests at all. This is the real problem, and it has targeted remedies;
  • the technical foundation is a dead end: abandoned language or framework, a server that can no longer be updated, an architecture that can’t support what the business needs next. Only here does a rewrite become a serious option.

It’s also worth asking who wants the rewrite, and why. A new agency naturally prefers working on a codebase it knows inside out. A team worn down by incidents sees a blank page as a promise of peace. Both are understandable, but neither tells you anything about the return on investment for the business.

So the right question isn’t “is the code nice?” but “what currently stops us from shipping, selling or sleeping at night, and what’s the least risky way to remove that obstacle?” Asked that way, the answer is rarely “throw it all away”, and almost never “don’t touch anything”.

The signals that genuinely justify a rewrite

Rewriting, whether the whole thing or one complete module, is defensible when at least one of these signals is present, and has been checked rather than just felt:

  • The technology has no future. A framework that no longer gets security fixes, a language version no reputable host still offers, a core dependency abandoned with no compatible replacement. If upgrading means rewriting most of the code anyway, you might as well do it with a plan.
  • The architecture contradicts the need. The classic example: an application built for a single customer that you now want to turn into a multi-tenant SaaS, while the concept of a customer account exists nowhere in the data. Or a synchronous process that now has to handle volumes the design simply can’t absorb.
  • The code can’t be deployed or tested reliably. No version control, changes made directly on the server, several diverging copies of the same file, no way to reproduce the environment locally.
  • The functional scope is small and well understood. Counterintuitively, this is the best case for a rewrite: an internal tool with a handful of screens and rules that fit on two pages can be rebuilt quickly and without surprises.

On the other hand, these arguments aren’t enough on their own: “the code isn’t clean”, “nobody uses that stack anymore”, “we’d be faster with framework X”, “the original developer left”. They describe real problems, but none of them require starting from zero.

A scenario we see regularly: an ageing PHP application with no tests, but whose business rules work and whose users know it by heart. New features are slow because nobody dares touch the core. A full rewrite would be the most expensive possible answer. What’s missing is a safety net (tests, a staging environment, automated deployment), followed by targeted replacement of the most painful modules.

What a rewrite really costs (the part the quote leaves out)

A rewrite quote usually prices the screens and visible features. The costs that derail these projects lie elsewhere:

  • Implicit business rules. A discount that doesn’t apply at weekends, a special rounding rule on certain invoices, a status that updates overnight. None of it is documented: it lives in the code, sometimes in a SQL query buried in a scheduled job. A rewrite forgets them, and users find out in production.
  • Data migration. Years of data entered under rules that changed along the way: empty fields, mixed formats, duplicates, broken references. Getting the migration right often takes as long as building a whole module.
  • Running two systems. Throughout the project, the old application keeps running, keeps having bugs and keeps receiving urgent requests. Either you keep evolving it, and every change has to be mirrored in the new one, or you freeze it, and the business waits.
  • A commercial freeze. Until the new version is live, launching anything new is hard. For a SaaS product, that can mean many months with nothing visible for customers while competitors keep moving.
  • Cutover. Launch day concentrates every risk: the final migration, new habits for users, and a rollback that’s hard to pull off if something goes wrong.

We won’t give you a “typical” percentage or timeline: it depends entirely on the size of the application and the state of the data. But one pattern holds on nearly every project we see: the older and more heavily used the application, the more the invisible part (implicit rules, data, cutover) outweighs the visible part. That’s exactly the part a quote written after a quick demo cannot estimate.

It’s also why a fixed-price rewrite offered without a prior audit should make you cautious. Either the supplier has padded the price heavily for the unknown, or they’ll discover it along the way, and the change-request conversation will start at the worst possible moment.

The alternative: modernise step by step, one module at a time

Incremental modernisation rests on a simple idea: instead of replacing the application in one go, you replace its parts one by one, in production, while everything else keeps running. The pattern is known as the “strangler fig”: the new application grows around the old one and gradually takes its place until nothing is left to replace.

In practice, you put a single entry point in front of both applications, often the web server itself, which decides which one answers which URL:

server {
    server_name app.example.com;
    root /var/www/legacy-app/public;

    # Modules already rebuilt: served by the new application
    location /billing/ {
        proxy_pass http://127.0.0.1:8081;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
    location /api/v2/ {
        proxy_pass http://127.0.0.1:8081;
        proxy_set_header Host $host;
    }

    # Everything else: the legacy application, untouched
    location / {
        try_files $uri /index.php?$query_string;
    }
    location ~ .php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
    }
}

Users see no difference: same domain, same session if you take care to share it, same screens until they’ve been rebuilt. For the team, each modernised module ships and gets used as soon as it’s ready, instead of waiting for the end of the project.

Choose the order by value and risk. We usually start with a module that hurts (slow, buggy, frequently changed) but has a clear boundary: an export, billing, the customer portal. Leave the most sensitive core for later, once the method has been proven on something smaller.

For critical calculations, we often run the old and new code side by side for a few weeks, comparing their results while the new code has no effect yet:

public function orderTotal(Order $order): int
{
    $legacy = $this->legacyCalculator->total($order);

    try {
        $candidate = $this->newCalculator->total($order);
        if ($candidate !== $legacy) {
            $this->logger->warning('Calculation mismatch', [
                'order'     => $order->id,
                'legacy'    => $legacy,
                'candidate' => $candidate,
            ]);
        }
    } catch (Throwable $e) {
        $this->logger->error('New calculator failed', ['exception' => $e]);
    }

    // The legacy result stays authoritative until the log goes quiet
    return $legacy;
}

The logged mismatches tell you precisely what the new version forgot. It’s the most reliable way we know to surface those implicit rules. Once the log stays quiet over a representative period (a month-end close, a peak season), you switch over and delete the old code.

This approach has its own costs: two codebases living side by side for a while, shared authentication, sometimes a shared database. But those costs are spread out and visible, and every step delivers something in production. And if the budget has to be cut halfway, the business keeps whatever has already been modernised, rather than half a rewrite nobody can use.

Before you decide: the audit that prevents expensive mistakes

A decision this size deserves a few days of audit, not an impression formed after an hour of browsing the code. Here’s what we check every time:

  • versions: language, framework, database, operating system. Which are still supported, and what does the upgrade path look like?
  • dependencies: how many are outdated, how many have known vulnerabilities, how many are abandoned?
  • reproducibility: can you install the application on a fresh machine from the repository, without copying the production server?
  • tests and deployment: are there any tests at all? How does a change actually reach production?
  • hot spots: which files change most often, and which ones keep showing up in incidents?
  • data: volume, quality, and the integrity constraints actually present in the schema.

Some of these questions can be answered with a few commands, run on a copy of the project:

# Versions and dependencies
php -v
composer outdated --direct
composer audit
npm outdated
npm audit --omit=dev

# The 20 most frequently changed files over a year: where the debt actually costs you
git log --since="1 year ago" --name-only --format= 
  | grep -v '^$' | sort | uniq -c | sort -rn | head -20

Cross-referencing the most frequently changed files with the largest ones, or with those most often mentioned in incident tickets, produces a very telling map: that’s where technical debt really costs money. An old, ugly file nobody touches costs almost nothing. A file changed every week that breaks every time is your priority, whether you end up rewriting or not.

The audit should also include users: which screens are slow, which tasks get worked around in a spreadsheet, which requests have been turned down for months because “it’s complicated in the code”. They’re often the ones who point to the right first module to modernise. At the end, you should have a document a non-developer can read: the current state, ranked risks, and two or three scenarios priced separately.

If you do rewrite: the rules that keep it on track

When a rewrite is justified, a few rules make the difference between a project that lands and one abandoned halfway:

  • Pin down behaviour before writing new code. Write characterisation tests against the old application: feed it real inputs, record the outputs, and require the new version to produce the same ones. An AI coding assistant is genuinely helpful for generating these tests in bulk, as long as someone reviews each one.
  • No new features in the rewrite. Version one of the new application does what the old one does, nothing more. Improvements come after cutover; otherwise the scope grows forever.
  • Rehearse the data migration. The migration script should run dozens of times against recent copies of production, with a report of rejected rows, long before launch day.
  • Ship in pieces, even in a rewrite. Even when the target is an entirely new application, nothing forces you to launch it all at once: one module, one group of users, one pilot customer.
  • Plan the rollback. As long as the old application can be switched back on and data entered in the new one can flow back, cutover isn’t a leap into the void.
  • Keep someone who knows the old system. The person who knows why a given edge case exists is worth more than any documentation.

One last point that’s often overlooked: decide up front what would stop the project. If, halfway through, the new version hasn’t replaced anything in production yet, that’s your cue to switch to an incremental approach rather than keep funding a big-bang launch that keeps slipping.

FAQ

How much does a rewrite cost compared with modernisation?

There’s no reliable ratio: it depends on the size of the application, the state of the data and how many implicit rules are buried in the code. What is certain is that incremental modernisation can be priced and paid for module by module, with a visible benefit at each step, whereas a rewrite commits a large budget before any return.

Our previous developer left with no documentation. Should we start over?

Not necessarily. Missing documentation is a knowledge problem, not a code problem. An audit, characterisation tests and a staging environment let you regain control of the existing system, then decide module by module.

Can an application be modernised without downtime?

Yes, that’s the main benefit of the incremental approach: each module is switched over separately behind the same URL, with a rollback option. Users see improvements arrive gradually.

Can AI rewrite our application for us?

It speeds up some tasks considerably: reading and summarising old code, writing characterisation tests, converting code from one language version to another. But it doesn’t know your implicit business rules and can introduce errors with complete confidence. It’s a tool within a method, not a replacement for one.

An ageing application, a full rebuild proposed by a supplier, features that no longer move forward? We audit your code, help you choose between rewriting and modernising, then run the transition without disrupting your business.

Partager LinkedIn Facebook X WhatsApp
</>

webtestudio

Agence web : sites WordPress sur mesure, thèmes premium et logiciels SaaS.

Parler de votre projet →