Lava Flow
Dead code accumulating at the project level over time.
“Code that nobody dares to remove because it might be needed.” – Brown et al.
Layers of obsolete technology and designs.
Signs of Use (Symptoms)
- Variable styles and patterns from different eras of the project.
- Huge chunks of commented-out code.
- Modules named
OldManager,NewManager,Manager2020.
Why it is bad (Consequences)
- Fear: Developers are afraid to modify code because they don’t understand it.
- Complexity: Navigating through dead layers to find live code.
- Bugs: Old, unused code might still be initializing and causing side effects.
Why it happens (Root Cause)
High turnover, shifting requirements, and lack of refactoring. “It works, don’t touch it.”
When it might be okay (Exceptions)
- Research prototypes where the goal is exploration, not maintenance.
Explanation
Problem
A project started in 2010. It has jQuery, then Angular 1, then React. Nothing was fully removed.
The Flaw
The codebase solidifies like lava. You have to work around the hardened “flows” of old code.
Real world analogy
A city built on top of ruins. You dig a hole and find Roman aqueducts mixed with modern pipes.
Refactoring Solution
- Strangler Fig Pattern: Gradually migrate to new system.
- Delete aggressively: Remove dead code. Verification comes from tests.
Pros and Cons (of the Antipattern)
| Pros (Why people do it) | Cons (The price you pay) |
|---|---|
Comparison
- Related Antipatterns: Boat Anchor, Dead Code.
- Related Principles: Boy Scout Rule (Leave code cleaner than you found it).
Code example
Typescript
Bad (The Antipattern)
Good (The Fix)
PHP
Bad (The Antipattern)
Good (The Fix)