Most software spends most of its life being maintained: fixing bugs, adapting to new systems, adding small features. Legacy code is code that works, matters, and is hard to change, often with no tests and no author left. Learning to work in it safely is one of the most valuable and least taught skills.
Key concepts
- Understand before changing: read, run, trace and draw before you edit a line.
- Safety net first: characterisation tests and small commits let you change what you do not fully understand.
- Seams: places where behaviour can be altered without editing the code around it, which let you test in isolation.
- Incremental replacement: wrap the old part, route traffic piece by piece, and retire it last.
- Dependencies age: libraries and platforms lose support, so upgrades are routine work, not emergencies.
Vocabulary
- Legacy code: working code that is hard to change, often defined as code without tests.
- Technical debt: the extra cost of future change caused by past shortcuts.
- Deprecation: marking something as obsolete before it is removed.
- End of life: the point at which a version no longer receives fixes.
What to study, in order
- Take an old project and get it to build and run on a clean machine; write down every step.
- Trace one feature from input to output and draw what you found.
- Add characterisation tests around one risky area before touching it.
- Learn to find and break dependencies in code that is hard to test.
- Plan an upgrade of an outdated dependency as a series of small, reversible steps.