Do you drive a vehicle? Do you change your tires? If so, then I am sure you don’t just throw your old tires away. You need to manage them in order to keep your project going in a positive direction. The same is true for legacy code.
Legacy code is old code that needs to be managed. As with tires on a vehicle, legacy code can drag it down and even stop it from moving forward if not taken care of properly. Also like tires, legacy code can be flat or worn out and need to be replaced in order to make the vehicle run smoothly again.
Good management of legacy code will keep your project moving in the right direction. Bad management of legacy code can cause more problems than it solves
Managing legacy code isn’t hard, but it does require thought and responsibility on the part of the developer. When you are adding new features, you should always look at the existing code and ask yourself if there is a better way to implement the new feature. This may mean refactoring some old methods or classes to make room for newer ideas.
Have you ever driven a car that had a flat tire? If so, then you probably know it is much harder to steer and control. You have to fight the wheel in order to keep the vehicle on course.
When software developers talk about legacy code, they are talking about code that is difficult to change. It has been unmaintained for quite some time, and it has many dependencies on other parts of the application. This makes it very difficult for anyone to change and maintain.
In this article, I will try to explain how legacy code is like a flat tire on your vehicle, and how you can use this analogy to help persuade your team or boss that managing your legacy code is important.
Legacy code is like a tire on your vehicle. Every time you drive, the tire creates friction and wears down the road. If you don’t maintain the tire, it will become flat and blow out while you are driving. You will be stranded in the middle of nowhere or worse, end up in an accident.
Think of your legacy code as that tire. You need to keep it in good condition so you can get to your destination safely. Like a tire, legacy code is constantly exposed to friction and wear and tear. Unlike a tire, legacy code does not have a manual on how to maintain it or even what maintenance needs to be done. It also doesn’t come with an easy way to tell when it has been worn down too much or has blown out completely. How do you maintain something when you don’t know what needs to be maintained?
We can learn from tires by looking at how they are maintained:
Developers often think of legacy code as a liability. However, we should think of our legacy code as an asset. Every line of code that is written and still works today is an investment into the future of your project.
In order for your project to function, you need to maintain this investment in your legacy code.
As a developer, you may be tasked with developing new features for your product and adding lines of code to your project. This is like maintaining the engine and adding fuel to your vehicle. If you keep adding fuel, but don’t change the oil or rotate the tires, then the vehicle will not be able to run over the long haul. The same goes for maintaining legacy code and adding new features: if you keep adding new features without refactoring legacy code, then it will be hard for your product to make progress over the long haul.
What is legacy code? Well, it’s simple. Legacy code is the tire on your vehicle. It works just fine. You might not like how it looks or how it handles, but you’re probably not going to remove it unless there’s something wrong with it.
You buy a brand new car and you’re super excited about how well everything works and how great it looks. Then, one day you hit a pothole and discover that one of your tires has a slow leak in the sidewall. Now you have to get that fixed… do you get a new one? A used one? Do you turn the tire around so the bad part isn’t on the ground anymore?
These are all terrible ideas. In fact, if you did any of these things, your car would be even worse than it was before. You could replace your tire with another good tire, but now you have no spare in case of an emergency. If you rotate your tires, wear will be uneven and they’ll fail earlier than they should.
But let’s say that instead of getting a new tire, what if we just patch up the leaky one really well so it doesn’t leak anymore? Sure, there’s still a weak spot in the
You may find yourself in a situation where you are taking over a project from someone else or your team inherited an old code base. If this is the case, you have what’s called a legacy code base.
What is Legacy Code?
This is code that was written by a past developer who has moved on to another project and no longer maintains it. This could be a set of applications that have been running for a long time and have been patched as new features have been added. It could also be code written by someone who didn’t know what they were doing.
The question that comes to mind is “Why do I need to manage it?” Well, if you don’t manage legacy code it can cause your project to slow down. Eventually, it will grind to a halt.
What do I mean by manage? I am talking about taking the time out of your development cycle to read through the code, understand how it works, and make changes when necessary so that you can avoid problems down the road.
Legacy code is code that has been around a long time. It is the application that has been built over the years incrementally, and sometimes haphazardly.
A legacy system could have started out as a simple “Hello World” application but has grown into a large, complex system that manages all of the business’s operations.
It may have been written by a small team of developers but now development on the project involves many more developers, and new features and bug fixes are added daily.
The system may be written in an older technology such as Perl or PHP4 or the code may be written in a newer technology like PHP5 or Ruby. But it doesn’t matter what language it is written in, or how much time has passed since its inception. The important part is that it is something that you need to manage over time and that this management itself can cause problems for you if it isn’t handled correctly.