Statistics prove that the legacy software struggle is real. According to a survey by Hitachi Consulting, 90% of IT decision-makers claim that legacy software is holding them back. What’s more, Vanson Bourne research suggests that 76% of respondents experienced a situation when critical data was not accessible, as it happened to be trapped within legacy systems.
When trying to tackle legacy software, developers have two main choices: they can either refactor or rewrite the code. In this article, we’re going to describe the main differences between these approaches. This comparison will help you decide which one is the best option for your legacy system modernisation.
What is software refactoring
First and foremost, refactoring is not equal to rewriting. Software refactoring improves the structure without changing the external behaviour of the system.
The refactoring process usually consists of small steps. After every completed stage, you’re left with a functioning system. If you can’t stop using the software, refactoring is an easier way to improve the quality of code.
In other words, refactoring changes the structure yet it doesn’t change the function. The final products both perform the same tasks, while the refactored one does it more smoothly. Refactoring leads to clear, easy-to-maintain code without turning the legacy system upside down.
Advantages of software refactoring
- (Typically) easy to start – Refactoring is always possible for the developers who have been working on the code so far. They already know it well, and they see things that need to be improved. What’s more, they usually don’t need any external approval to start refactoring the code.
- Suitable for all kinds of software architecture – You can refactor different types of software, no matter if it’s monolithic or modular.
- More flexible – Sometimes the problem lies mainly in one part of the system. In this case, the developers can choose to refactor selected segments only. This kind of flexibility makes it more affordable, too.
- Sticks to one codebase – When refactoring, you don’t have to create two separate codebases. This approach decreases maintenance costs.
Challenges of software refactoring
- Doesn’t always solve the problem – The issue doesn’t always lay in the structure. If the problem is functional, usually the only option left is rewriting.
- Requires a lot of expertise – Refactoring requires a different skill set than creating software from scratch. In this case, the developers have to deal with plenty of complex patterns and ambiguities.
- Unit testing – Having a stable unit test suite is necessary for successful refactoring. Without it, the process can soon become overwhelming. When you plan your refactoring activities, be sure to include testing in the schedule.
What is software rewriting
Software rewriting, on the other hand, changes not only the structure but also the function of your system. In this case, the programmers create new code entirely from scratch.
Advantages of software rewriting
- Wide range of possibilities – When rewriting, you’re not limited by the previous structure of the system. You can start everything from scratch and implement innovative solutions that you couldn’t consider before. For instance, when the legacy system is a decades-old Windows desktop app, a rewrite allows you to turn it into a web-based platform.
- Acquisition-friendly – If the people who have created the legacy software are no longer there, rewriting is a much better option. This way, the new software development team can start working on their own terms, without trying to untangle old and messy lines of code.
- More future-oriented – Rewriting legacy code will save you frustration in the future, including the kind of frustration you’re dealing with right now. By recreating everything from scratch, you will be able to avoid the mistakes you’ve already noticed in the old system. What’s more, this is an opportunity to focus on proper documentation. This way, you’re less likely to fall into the same trap again.
Challenges of software rewriting
- Time-consuming – This might be the most prominent disadvantage of software rewriting. Creating new systems from scratch takes a lot of time, and not every company is able to make such a big investment to tackle their legacy software issues.
- Two codebases – When rewriting your legacy systems, you need to maintain two codebases simultaneously, both the old one and the new one. This generates additional costs that can be avoided when you’re refactoring existing software.
- New doesn’t mean better – Unfortunately, this is a common trap that comes with rewriting legacy software. The rewrite can be free of the old issues, yet it doesn’t mean it won’t bring new ones to the table.
Code refactoring or rewriting: what to do with your legacy system
If we were to choose a relevant illustration, refactoring is like replacing the broken bricks in the wall. Rewriting is like tearing down the wall and building it again from scratch.
This example emphasizes one of the most important rules to remember. If you’re only dealing with minor issues that generate some problems from time to time, refactoring should be enough. However, if the product leaves a lot to be desired, rewriting is the way to go.
Sounds rather simple so far? Of course, there are other things to be considered, as well.
Factors to keep in mind
- Your in-house team – Are the people who built the system still working in the company? If the answer is yes, refactoring can be a better fit. The developers who can understand the code will find it easier to make small changes. If it’s not possible, a rewrite will make a better option.
- The current trends – You might want to rewrite the app in, let’s say, Flutter, just because it’s been trending lately. Although it may turn out to be a good idea in some cases, this isn’t a strong enough motivation for rewriting the whole system. Before you make that decision, be sure to explore the opportunities for your existing code.
- Real-time features – Need a live chat or another kind of real-time service? If your legacy software is unable to provide these, it doesn’t always mean you need to rewrite it. Instead, you can use an external live chat solution and implement a module on your website.
- Maintenance costs – If the maintenance of your legacy systems is becoming overwhelming, it might be a sign that it’s time to consider rewriting your software. This kind of investment is very likely to pay off in the long run.
- Architectural shifts – If you’ve already decided you’re moving your system to another architecture, e.g. from a monolith to microservices, it’s the right moment to rewrite the whole app.
Let’s talk about your project!
Still not sure which option will work best for your legacy system? At Miquido, we know how to evaluate legacy software and choose the right next steps. Get in touch and we’ll help you with refactoring and rewriting your digital product!