Why You Should Embrace the Job of Maintaining Old Code

You are a legacy coder

Once, I worked on a big telecom project. There were several international teams involved in the project. The project was quite old already—more than 10 years of C/C++ code, and it had several hundreds of thousands of lines of code.

The project also included an old tolling and setup, done 10+ years ago, and nobody wanted to touch it.

As part of the new team, we had to travel to meet the original team of developers and spend several months learning the basics of the code. At first, it seemed like a lot, and the project looked hopeless. There was a lot to learn, nothing worked, and nothing made sense.

But when I looked back, it was one of those times when I learned the most - not just about the code and programming, but also about team management and managing big projects.

You are a legacy coder

According to the 2020 Developer Survey by Stack Overflow, over 70% of developers are involved in maintaining or improving existing code. Expect that at most jobs, you will be maintaining the old code.

And even when producing a new code, that code will become old the next day. You will have to maintain it.

Studies indicate that developers spend approximately 50-70% of their time understanding existing code. Be prepared to read a lot of code. Even your code will look ancient to you after a month.

How to understand and maintain legacy code

Understand the business logic: It's vital to understand the business logic behind the old code to make proper decisions during maintenance. Understand the ‘why’ first. Understanding legacy code requires patience and a deep understanding of the original developers' intent.

Identify key components: Start by identifying and understanding the key components and modules in the legacy system.

Embrace documentation: Good documentation can ease the process of understanding and working with legacy code. If it is not there, create one. It will help you later.

Testing: Invest in writing tests for existing code to ensure any changes do not introduce new bugs. It is important to communicate with the team the importance of the tests. It gives you stability and confidence when making changes to the old codebase.

Refactoring: Learn when and how to refactor legacy code without breaking functionality. Tests need to be done first. Beware of any refactoring early in the process. The old code can be tricky. Refactor codebases gradually while maintaining functionality. Refactor small, isolated, less critical parts first.

Communication: Frequently communicate with stakeholders to understand their needs and explain the implications of working with legacy systems. When you make changes to legacy systems, keep your team informed. Changes can have wide-reaching implications.

Prioritize changes: Prioritize changes based on business needs, potential risks, and dependencies. At the same time, make sure the changes are incremental and covered with good tests.

Monitor and review: Continuously monitor the impact of changes and review the code with peers for quality assurance.

Develop a migration plan: For outdated technology, have a long-term plan for gradual replacement. This might require longer planning and communication. Make sure the stakeholders approve such changes upfront. Be prepared that the legacy system can stay this way for years without being upgraded to something new.

Difference between legacy system and newly-built systems

Legacy systems differ from newly built systems:

Reliability: Legacy systems are often stable and well-tested through years of use.

Savings: Maintaining and improving legacy systems can be more cost-effective than complete rewrites. Creating software is a serious investment. This investment must pay off. And it might take years.

Continuity: Continuous operation without business disruption is often easier with legacy systems. The stability and reliability of the system is important for business. Thus, changes must be done with care and rigorous testing.

Knowledge accumulation: Working on legacy code helps developers learn about system intricacies and business logic. When you look at the legacy system, many things might not make sense or be completely wrong. Do not judge the previous decisions before you know the whole story.

Skill enhancement: Developers can enhance their problem-solving and debugging skills while working on legacy systems. Also, testing skills and deployment pipelines are different in legacy environments, which can be a good way to learn something new.

Documentation: The old systems often need proper documentation. Adding and updating the documentation is a big part of maintenance. The documentation will also help new developers quickly become proficient with the legacy system.

Tech debt: Naturally, technical debt in a legacy code can play a huge role. This has implications for planning and productivity. Many things will take more time, including development, adding tests, adding documentation, and careful deployment.

Legacy systems often run critical business processes that cannot be easily replaced. So, complete system rewrites are risky and can lead to business disruption. Prefer incremental improvements to legacy systems. This can assure significant benefits over time with less risk.

Why update the legacy systems when they work reasonably well?

Here are a few reasons.

Security: Legacy systems may not incorporate modern security practices, making them vulnerable.

Performance: Older systems not optimized for current volumes of data/transactions can become bottlenecks.

Integration: Modern systems often need help to integrate seamlessly with legacy technologies.

User Interface: Legacy systems often have interfaces that do not meet current usability standards.

Why you need to learn to live with legacy code

Even if ‘code maintenance’ and ‘legacy code’ sound bad for many developers, the fact is you will need to live with it. Embrace it. Here is why.

Presence: Legacy systems are everywhere; learning to work with them is inevitable.

Job security: Skills in maintaining legacy systems can lead to more stable job opportunities.

Complex problem-solving: Legacy code offers complex, real-world problems to solve, which can be intellectually satisfying.

Professional growth: Tackling legacy code can accelerate professional development.

Impact: Contributions to legacy systems can have a significant, immediate impact on business operations.

Learning: There is much to learn from existing code, such as architectural patterns, coding styles, and domain knowledge.