Definition of "Legacy Code"
By: Johnathon Wright on: January 08, 2021
I had an interesting discussion with a client recently. I had used the word "legacy" to refer to parts of their codebase. They then repeated the word, but with somewhat more negative connotation. So I'm writing here to firm up my definition of what it means to be legacy. Here are some thoughts I got from a Slack channel:
- [Kathryn] it's not a good definition, but i've always found that people just say "legacy" if it was there before they were haha
- [Red] Or uses libraries, frameworks, or languages that are either no longer seeing wide usage or just plain dead
- [Andrew] I agree with @kathryn, but to put it fancier I think it often means code where the knowledge to maintain it is not organizationally shared and remains in the hands of a few senior developers
- [Kathryn] That's a really good point too -- about lack of shared knowledge
- [jag] Legacy code is "code I didn't write and want to normalize rewriting versus learning how it works"
- [Brian] I recently heard someone use "legacy" to refer to a 3 year old because it uses an older version of angular. They have another application that is 20 years old that uses ocx controls that they consider legacy as well. Those seem different to me.
- [jag] But I think it started out meaning what @Red said - just that it's slipped down the slope.
- [Nick] I’ve always considered legacy to be the “old” product or code that is in the process of being replaced by something newer and shinier, and typically just in maintenance mode where any new features get added to the new/shiny thing
- [Brian] Interesting. I think I've used it more to define things that should be replaced. Your definition is clearer in the sense that it's a system that isn't going to be used later.
- [Red] Yeah I was trying to think of what the definition should be, but I'll definitely agree that what you all said is far more common of how its really used. :)
I mean I think most would agree that a bunch of ancient COBOL programs are "legacy code", but that doesn't mean that its about to be replaced. - [mark] I've used it both ways...as in "old code"...which often (but not always) means it out of date or lacking in some way. But there is often a bias where developers who originally wrote or architected the code are reluctant to use that term to describe it.
- [Red] We're all sensitive to age to some extent - nobody wants to be called "legacy"
- [Jacob] legacy code is that code you hate and/or don't understand but can't get rid of
- [egg] I’d call it code that’s become difficult or impossible to change, whether that’s because knowledge about it has been lost, or because it’s been poorly maintained for an extended period of time (possibly on top of poor architecture).
- [Tracy] I work in, correct problems and add new features to a code base that was started back in the early 1980s. Since the code is not the "new thing" and the language is no longer supported by the company that wrote it. I work in legacy code all day.
- [Paul] "Working Effectively With Legacy Code" defines it as "Any code you're afraid of," which prompted me to observe that most startups produce legacy code the moment it leaves the programmers' fingertips.
- [tim] maybe, it's better that I work on the legacy project. But some of the code in our system is very difficult to touch and it is brittle.
- [Red] Yeah I like that - it doesn't imply that its about to go away, but it does imply the end of real investment.
- [mullican] A fuller quote from the book Working Effectively with Legacy Code:
- [haizop] I would say that "legacy" usually implies:
- the code is somehow organizationally antecedent to current development initiatives. Something has changed, either there is a new team, a new product, etc.
- AND the code is deemed to be technically out of line with current initiatives, for any number of reasons, be they libraries are out of date, architecture is deemed bad, etc.
- [Paul] Yeah. To me, the key question isn't really about the code you have, but about the code you want. It's amazing to me how many times I've heard "let's refactor this." OK, fair enough. But refactor it to what?
- I think we generally agree on the following:
- The definition between what it really means and what people use it to mean are different.
- What it actually means is code that has been in production for some extended period of time, where the domain knowledge around the code is rather specialized, and where the age of the codebase shows in terms of hacks, workarounds, kludges, and tightly-coupled codepaths.
- People often misuse the term to mean code they wish didn't exist anymore and to imply/wishcast that the code ought to be replaced with newer code, in part because people like building new things, in part because people tend to underestimate the domain complexity, and in part because people don't want to take the time to understand it.
Is that fair?
- [Jacob] it's also a scapegoat to get out of work "oh that's built on legacy code and only bob can work on that"
- [Paul] It can be that, but to @haizop's point, it can be perfectly legitimate to say "that system isn't consistent with our current architecture." And "it would be prohibitively expensive to rewrite."
- [Andrew] To that last point @Paul Snively I think another aspect of this is that it's code you shouldn't copy/use as a model for new code. Telling a new engineer, "that's legacy" is a way of saying, we don't do it like that anymore
- [Paul] Which is not at all to say "it has no value" (it's probably generating revenue!) or "the people who wrote it were idiots" (no; they were working under different constraints).
- [Jacob] i maintain a php app that was started in 1998. after about 7 years of hacking on it it was a huge mess that needed to be iterated towards something more maintainable. no budget or time for that. so they decided to rewrite the whole thing from scratch, in cold fusion. in 2007-8 (right around when there was about 7 people actively writing new apps in coldfusion). after about 3-4 years and who knows how many millions spent, it launched with 1/4 the features and 10x the bugs and 3x the maintenance costs. the coldfusion app got shuttered last year. the php one is still going.
- [Paul] I don't think I've heard of Cold Fusion since 2007.
- [jag] CFML PTSD I think is actually in DSM-V.
- [Paul] That's another thing I don't get: "We're going to take the same team that wrote system X, not do any new training or hiring, not going to significantly change technology, but we're going to rewrite system X, and it'll be much better."
- [Jacob] no no no. they hired a whole new team while not telling my team it was being rewritten. just that my budget was frozen.
- [jag] It's a way of saying "Those mistakes were so much fun to make the first time - let's make them again!" Throwing away domain experience is just setting fire to money.
- [Paul] It's such a weird idea, that software developers are interchangable cogs, when we're much closer to heart surgeons.
- [Andrew] Heart surgeons who operate on different species of animals, including some aliens that have unique heart configurations no one has ever seen before
- [haizop] Few things at work annoy me more than hearing a PM refer to an engineer as a "resource".
I had an interesting discussion with a client recently. I had used the word "legacy" to refer to parts of their codebase. They then repeated the word, but with somewhat more negative connotation. So I'm writing here to firm up my definition of what it means to be legacy. Here are some thoughts I got from a Slack channel:
- [Kathryn] it's not a good definition, but i've always found that people just say "legacy" if it was there before they were haha
- [Red] Or uses libraries, frameworks, or languages that are either no longer seeing wide usage or just plain dead
- [Andrew] I agree with @kathryn, but to put it fancier I think it often means code where the knowledge to maintain it is not organizationally shared and remains in the hands of a few senior developers
- [Kathryn] That's a really good point too -- about lack of shared knowledge
- [jag] Legacy code is "code I didn't write and want to normalize rewriting versus learning how it works"
- [Brian] I recently heard someone use "legacy" to refer to a 3 year old because it uses an older version of angular. They have another application that is 20 years old that uses ocx controls that they consider legacy as well. Those seem different to me.
- [jag] But I think it started out meaning what @Red said - just that it's slipped down the slope.
- [Nick] I’ve always considered legacy to be the “old” product or code that is in the process of being replaced by something newer and shinier, and typically just in maintenance mode where any new features get added to the new/shiny thing
- [Brian] Interesting. I think I've used it more to define things that should be replaced. Your definition is clearer in the sense that it's a system that isn't going to be used later.
- [Red] Yeah I was trying to think of what the definition should be, but I'll definitely agree that what you all said is far more common of how its really used. :)
I mean I think most would agree that a bunch of ancient COBOL programs are "legacy code", but that doesn't mean that its about to be replaced. - [mark] I've used it both ways...as in "old code"...which often (but not always) means it out of date or lacking in some way. But there is often a bias where developers who originally wrote or architected the code are reluctant to use that term to describe it.
- [Red] We're all sensitive to age to some extent - nobody wants to be called "legacy"
- [Jacob] legacy code is that code you hate and/or don't understand but can't get rid of
- [egg] I’d call it code that’s become difficult or impossible to change, whether that’s because knowledge about it has been lost, or because it’s been poorly maintained for an extended period of time (possibly on top of poor architecture).
- [Tracy] I work in, correct problems and add new features to a code base that was started back in the early 1980s. Since the code is not the "new thing" and the language is no longer supported by the company that wrote it. I work in legacy code all day.
- [Paul] "Working Effectively With Legacy Code" defines it as "Any code you're afraid of," which prompted me to observe that most startups produce legacy code the moment it leaves the programmers' fingertips.
- [tim] maybe, it's better that I work on the legacy project. But some of the code in our system is very difficult to touch and it is brittle.
- [Red] Yeah I like that - it doesn't imply that its about to go away, but it does imply the end of real investment.
- [mullican] A fuller quote from the book Working Effectively with Legacy Code:
- [haizop] I would say that "legacy" usually implies:
- the code is somehow organizationally antecedent to current development initiatives. Something has changed, either there is a new team, a new product, etc.
- AND the code is deemed to be technically out of line with current initiatives, for any number of reasons, be they libraries are out of date, architecture is deemed bad, etc.
- [Paul] Yeah. To me, the key question isn't really about the code you have, but about the code you want. It's amazing to me how many times I've heard "let's refactor this." OK, fair enough. But refactor it to what?
- I think we generally agree on the following:
- The definition between what it really means and what people use it to mean are different.
- What it actually means is code that has been in production for some extended period of time, where the domain knowledge around the code is rather specialized, and where the age of the codebase shows in terms of hacks, workarounds, kludges, and tightly-coupled codepaths.
- People often misuse the term to mean code they wish didn't exist anymore and to imply/wishcast that the code ought to be replaced with newer code, in part because people like building new things, in part because people tend to underestimate the domain complexity, and in part because people don't want to take the time to understand it.
Is that fair?
- [Jacob] it's also a scapegoat to get out of work "oh that's built on legacy code and only bob can work on that"
- [Paul] It can be that, but to @haizop's point, it can be perfectly legitimate to say "that system isn't consistent with our current architecture." And "it would be prohibitively expensive to rewrite."
- [Andrew] To that last point @Paul Snively I think another aspect of this is that it's code you shouldn't copy/use as a model for new code. Telling a new engineer, "that's legacy" is a way of saying, we don't do it like that anymore
- [Paul] Which is not at all to say "it has no value" (it's probably generating revenue!) or "the people who wrote it were idiots" (no; they were working under different constraints).
- [Jacob] i maintain a php app that was started in 1998. after about 7 years of hacking on it it was a huge mess that needed to be iterated towards something more maintainable. no budget or time for that. so they decided to rewrite the whole thing from scratch, in cold fusion. in 2007-8 (right around when there was about 7 people actively writing new apps in coldfusion). after about 3-4 years and who knows how many millions spent, it launched with 1/4 the features and 10x the bugs and 3x the maintenance costs. the coldfusion app got shuttered last year. the php one is still going.
- [Paul] I don't think I've heard of Cold Fusion since 2007.
- [jag] CFML PTSD I think is actually in DSM-V.
- [Paul] That's another thing I don't get: "We're going to take the same team that wrote system X, not do any new training or hiring, not going to significantly change technology, but we're going to rewrite system X, and it'll be much better."
- [Jacob] no no no. they hired a whole new team while not telling my team it was being rewritten. just that my budget was frozen.
- [jag] It's a way of saying "Those mistakes were so much fun to make the first time - let's make them again!" Throwing away domain experience is just setting fire to money.
- [Paul] It's such a weird idea, that software developers are interchangable cogs, when we're much closer to heart surgeons.
- [Andrew] Heart surgeons who operate on different species of animals, including some aliens that have unique heart configurations no one has ever seen before
- [haizop] Few things at work annoy me more than hearing a PM refer to an engineer as a "resource".