Site icon Experiences Unlimited

Why is the legacy code is the way it is?

google search for define: legacy gives:


Noun: An amount of money or property left to someone in a will.

Adjective: Denoting software or hardware that has been superseded but is difficult to replace because of its wide use.

Most of us would have worked on legacy code OR are working on it OR are even creating legacy code (!!). Just the thought of working on legacy code makes developers spend sleepless nights (yeah, slight exaggeration, but required to highlight the pain). We have yelled and cursed while working on legacy code. Lets step back and reflect a bit about legacy code and see how it can be tackled (if at all!)

What is legacy code?

At the start of the post I tried to get some definition for the term: “legacy”. (we wish if the noun was true! but indirectly they are one of the reasons for our pay). The adjective definition is somewhat closer to our “legacy code”.

Legacy code is something:

Legacy code which was written previously

Quite often you wish to develop a system/software from scratch but you end up working on a code that has been written 10years before or even earlier. We always yell and curse the one who wrote that code and we spend more time in understanding the code than adding something new/fixing some bug in the code. Any attempt to change the code would put us in danger of breaking some other functionality. Sometimes the code would have been written in a language which we are not familiar with ( there cant be anything worse than reading a code which is difficult to understand and in a language we are not familiar with) or other times just to get the code working/building the code is a huge task.

Why is it so?

Legacy code which is being written

Yes, we all write legacy code, atleast we cant call it right away, but 6 months or 1 year down the line the code is equivalent to the pain of legacy code. In few places it all the reasons stated above would hold, but considering the current advancements in langauges and platforms (advent of object orientation, or other paradigms, TDD, agile practices) there would be less concerns about the testability, manageability, readability of the code. The possible reasons why we write legacy code would be:

I just listed a few possible reasons as to why the legacy code is like the way it is. There might be more and I would be missing, feel free to chime in and I would be more than happy to accommodate them in my post.

There are lot of aspects related to legacy code- like how to work with legacy code. I would like to cover working with legacy code sometime in future. There’s also a book: “Working Effectively with legacy code” written by Michael Feathers, I havent read this book yet, but might be useful read.

Exit mobile version