Legacy code – a serious problem in software development?

Idego Idego • Mar 14
Post Img

In case you’ve read our latest blog post about problems in software development, you know that legacy code was one of the most burning ones. There are a lot of myths out there related to this term. This is why we decided to interview our developers to find out how they perceive legacy code and how they deal with it. Check it out!

What is legacy code?

Legacy code is a term related to the code that is written in an inefficient way. This usually means that the code was:

  • written by someone else, and now is not readable to new developers, 
  • written in an outdated, inefficient or niche technology that is not familiar to new development team members 
  • not tested or not well-documented.

Basically, legacy code is a code that became difficult to develop or maintain. How do developers see this issue themselves? 

“In my eyes, legacy code is the one that requires transformation – most frequently due to change of business requirements or availability of more modern and efficient technologies that force code restructuration” – says Damian, a back-end developer working with Python and Django. 

Karol, responsible for software development and legacy code projects, doesn’t like this term at all. He calls it a stigma. “Legacy code appears when the project was not properly tested and documented and passing it to a new developer requires a huge effort”. He also adds: “In fact, every project becomes a legacy project after a while. It’s an inevitable part of project maintenance, as technologies develop rapidly and do get outdated. Such projects are tough for many developers, but for me, they are fascinating, and dealing with them made me learn plenty of best practices”

Adam, a software architect programming in Java and JavaScript, shares the story: “I’m currently working on a typical legacy code project – I’m re-writing software for a major automotive company. The software has been used for 30 years. A big part of the documentation is lost, developers have switched over the years, and serious maintenance-related problems appeared. The code has grown over the years, and now the app resembles a blend of functionalities rather than a consistent tool. That’s a typical story”.

What’s the reason for legacy code?

What are the reasons for legacy code and are there any ways to prevent it?

“The main reasons for legacy code are lack of testing, lack of documentation and lack of skills and awareness. I would even say that testing is the most important, as it helps to estimate how a particular change in the code will influence the functionality. Negligence of testing means thinking in the short-term perspective” – says Damian.

Adam: “The factor that fosters legacy code is building monoliths. Microservices are much easier to re-write, maintain and keep updated. Also, the ability to write and read UML diagrams by developers might be helpful, as they are an important part of the documentation. As a best practice for prevention, I would also add a deep understanding of the app’s logic before re-writing any of its parts, and defining efficient unit tests”.

Karol: “It’s very important to build the app in the right way from the beginning. Having the files scattered across internal and external sources, not designed in the form of a consistent and integrated module, leads to chaos”.

How to deal with legacy code?

So are there any ways to deal with legacy code? 

“I know it sounds controversial, but in my opinion eliminating legacy code is impossible” – says Damian. – “The development process is a creative process. Trends and methods are changing rapidly, and it’s natural that the code ages. Being aware of that brings a kind of relief”. He also adds: “However, one of the best practices that might be helpful is a strategic approach to customer’s problems. Understanding the importance of the initial stages of the project and dedicating more time to the planning and preparation phase will help to reduce the risk of legacy code in the future”.

“One of the best practices is running regular tests. If we, as developers, neglect them, we basically cut our own throats. It’s impossible to develop without testing, and building tests from scratch within a mature project is really tough” – says Karol – “Moreover, the developer must remember that the code is written once, but then read over and over again thousands of times, by many people. This is why it’s important not to follow the trends uncritically, but make the code readable for everyone, even those who are not updated with niche technologies”.

Legacy code in business

What’s the clients’ attitude to legacy code? How do they react to the technology-related changes?

“Re-writing a huge application is a significant cost. This is why it’s difficult to explain this need to business people. They usually don’t understand why they need to pay for coding that will not provide them with new functionalities. They often realize it too late, when it’s already difficult to find developers capable of maintaining or developing the project, and also former employees are no longer able to keep up” – Adam explains. 

“Some clients don’t understand why they need to pay for rebuilding a software that was just released, let’s say no later than 2-3 years ago. Sometimes it requires dozens of meetings and calculations to finally convince them that legacy code is a huge risk. There are already a number of available trainings on how to deal with legacy code, however, they are useless if the business doesn’t see their value” – adds Karol.

“From my perspective, it’s important to be assertive. It happens that the client requires new functionality, but doesn’t predict the risk. Then it’s our role to explain the issue and suggest an alternative. This is how we not only build a code that is easier to maintain but also strengthen the partnership” – says Damian.

Developers on legacy code – summary

Let’s sum up our findings of legacy code:

  • Legacy code is a pain to many, especially young, developers.
  • However, dealing with legacy code is inevitable in developers’ work.
  • The biggest problems with legacy code are lack of testing, lack of documentation and code illegibility.
  • In order to improve the code quality, it’s a must to follow best practices: preparing documentation, running tests and writing readable code (while using proper techniques, patterns and tools).
  • Lack of understanding from business decision-makers and communication issues are severe problems. Clients must be educated about the importance of fighting against legacy codes and the potential consequences of negligence.

Adam: “We definitely need to stop frightening younger developers with legacy code. It’s common to offer maintenance projects to juniors, as more experienced developers obviously prefer more creative tasks. This is why those who are inexperienced don’t feel the excitement, but the truth is that thanks to this they can learn a lot.”

Damian: “Legacy code shouldn’t be perceived as a threat. However, working with it requires a special attitude. It’s like maintaining an old vehicle – there is always something that needs to be checked, fixed or investigated. In my eyes, legacy code projects can provide a developer with a huge dose of satisfaction and invaluable business knowledge”.

What is your experience with legacy code? Let us know in the comment.


Leave a Reply

Your email address will not be published. Required fields are marked *

Drive tactical delivery
without inflating the top line

Your Swiss Army Knife in AI, Cloud and Digital

Get in touch Button Arrow

info@idego.io

GPTW Poland 2022 GPTW Poland GPTW Europe Lider Clutch Review

We value your privacy

We use cookies to enhance your browsing experience, serve personalized ads or content, and analy Read More

Accept