Legacy Code

That stuff that other people wrote. They've all since left the company, so there's nobody left who knows how it works. It really needs to be refactored properly (preferably rewritten), but there's no time, and everything's using it.

Worse, the people who wrote it originally might still be in the company. They're too busy (and it was too long ago for them to remember) to answer questions on how it works, and they've got too much ego invested in it to countenance anyone rewriting it.


Code is not an asset, it's a liability [SoftwareAsLiability]. So many business people get this one wrong. "But we have millions of lines of code, it's our family jewels!". Wrong! I can slurp gigabytes of code off the net? Am I rich?

The more land I have, the richer I am. The more cows I have, (the Zulu have it right), the richer I am. The more code I have, the poorer I am.

What is true of code, is true also of land and cattle. It is not the amount that matters, it is the value density. An old cow that eats a lot but produces no milk or calves is a liability, not an asset. Land that yields 200 bushels of apples per acre is less valuable than land that yields 1000 bushels per acre.

A man with 200 head of cattle is poorer than a man with 100 head of cattle that produce the same amount of meat, milk, and calves as the larger herd.

Some code is an asset, just as some land and some cows are assets. Code with low value density or negative net value is a liability - crappy code is bad, crappy cows are bad, crappy land is bad.

It's the functionality and flexibility and extendability of code that is the asset, the number of lines of code is the liability. Therefore RefactorMercilessly and grow rich. Add kludges and the liabilities column of your balance sheet grows until you go bankrupt.


Legacy Code
"Any and all systems that are currently in production." ;->


Legacy is the stuff I wrote yesterday.


The IT industry must be one of the few places where a "legacy" is automatically considered a bad thing. In any other circumstances I'd assume that someone had left me some money.

http://www.joelonsoftware.com/articles/fog0000000069.html is one man's take on TheMozillaProject's decision to dump the Netscape LegacyCode


Legacy code is not just old code, or stuff other people wrote, or even code that is in production. Legacy code is any code that significantly and continually resists the reflection of on-going requirements change. -- Anthony Lauder

There's a book by Brodie and Stonebraker called "Migrating Legacy Systems: Gateways, Interfaces and the Incremental Appraoch" (ISBN 1558603301 ). It defines a legacy system as any information system that resists change.

-- ArieVanDeursen


At XP2000 we had a paper on LegacyCode called Legacy to the Extreme (see http://www.cwi.nl/~arie/papers/xp2000.pdf). We explored how ReverseEngineering tools help to make legacy Cobol code a bit easier to maintain. Moreover, we showed how several of the XP practices can be adopted to actual Cobol code, which we illustrated using real life (help!) Cobol LegacyCode.

-- ArieVanDeursen

''I appreciate the problem, having had to deal with legacy code myself. I think it's unfortunate that the computer industry is choosing to use the term "legacy" to always mean "that old junk we're stuck with", since it also has a delightful and beautiful connotation of

"the grand vistas we get from standing on the shoulders of giants; all that has been passed down to us by previous generations who have gone before us."

I think that the software industry is worse off for closing the possibility of using the term "legacy code" to mean "great software and ideas we're glad the people before us have left for us". I discuss this idea further on WhyDiscardOnesLegacy.''


The reason legacy code generally has bad connotations is that OldCodeRusts.

Legacy Code n. - code without tests.


Some great books that will help you work with LegacyCode are:


See also OtherPeoplesCode, StudyTheSourceWithaDebugger, UnitTestingLegacyCode, RewriteCodeFromScratch


CategoryJargon

EditText of this page (last edited November 7, 2011) or FindPage with title or text search