Course contentsShow
← Software Engineering
Lesson 1749 of 1,93351. Legacy Code and Brownfield DevelopmentFree lesson

Defining Legacy Code

Understanding what makes code 'legacy' and recognizing the characteristics that distinguish it from greenfield development.

Defining Legacy Code

You'll learn what distinguishes legacy code from new development and why that distinction matters for how you work.

What Makes Code "Legacy"?

Legacy code often conjures images of dusty, ancient systems written in COBOL decades ago. But the reality is more nuanced and less about age. Legacy code is code without adequate tests that you're afraid to change. Even code written last month can be legacy if modifying it feels like defusing a bomb.

The term describes code that works (usually) but lacks the safety nets and clarity that make confident modification possible. It's production code that the business depends on, but that engineers approach with trepidation.

Key Characteristics

Lack of Test Coverage: The defining trait. Without tests, you can't verify changes didn't break something unexpected.

Unclear Intent: The code works, but why it works or what business rules it implements may be mysterious. Comments are sparse or outdated.

Fear of Change: Teams avoid touching it. Bug fixes take weeks because every change risks cascading failures.

Knowledge Silos: Often only one or two people (if any) understand how it really works.

Brittleness: Small changes in one area break seemingly unrelated features.

Legacy vs. Greenfield

Greenfield development means building something new from scratch—you choose the architecture, tools, and patterns. Legacy work means inheriting existing systems with their accumulated technical decisions, some good, some questionable, all permanent until proven safe to change.

Key Takeaway: Legacy code isn't defined by age or technology—it's code you're afraid to change because you can't easily verify the impact of your modifications, typically due to missing tests and unclear design.