Lava Flow
An anti-pattern where dead or experimental code hardens into production systems and becomes difficult to remove.
Also known as: Lava Flow Anti-Pattern, Dead Lava
Category: Software Development
Tags: software-engineering, anti-patterns, code-quality, maintenance
Explanation
Lava Flow is a software anti-pattern where code that was once experimental, temporary, or provisional becomes permanently embedded in a production system. Like volcanic lava that cools and hardens into rock, this code solidifies into the codebase and becomes increasingly difficult to remove.
## How lava flows form
- **Prototypes go to production** - Quick proof-of-concept code ships without being rewritten
- **Abandoned experiments** - Code from features that were never completed lingers
- **Developer turnover** - Nobody knows why the code exists, so nobody dares remove it
- **Missing tests** - Without tests, removing code might break unknown functionality
- **Fear of regression** - 'It works, don't touch it' mentality
- **Time pressure** - No time allocated to clean up old code
## Symptoms
1. **Large blocks of commented-out code** - Code that was disabled but not deleted
2. **TODO/FIXME comments from years ago** - Intentions that were never acted on
3. **Unused variables, functions, and classes** - Code that nothing references
4. **Mysterious configuration** - Settings for features that no longer exist
5. **Dead branches in version control** - Feature branches that were never merged or deleted
6. **Undocumented workarounds** - Hacks that solved problems that may no longer exist
## Consequences
- **Increased complexity** - More code to understand, navigate, and maintain
- **Misleading context** - Developers waste time trying to understand dead code
- **Build time** - Dead code still gets compiled and processed
- **False positives** - Static analysis tools report issues in code that doesn't matter
- **Security risk** - Unused code may contain vulnerabilities that are never patched
## Prevention and remediation
- **Delete aggressively** - Version control means you can always get it back
- **Code review** - Catch provisional code before it merges
- **Static analysis** - Use tools to identify dead code
- **Feature flags** - Remove old flags and their associated code paths
- **Regular cleanup sprints** - Allocate time specifically for removing lava flows
- **Boy Scout Rule** - Remove dead code whenever you encounter it
The key insight is that keeping code 'just in case' has a cost. The code is always available in version control history if truly needed.
Related Concepts
← Back to all concepts