principleModeratepending
Principle: Optimize for deletability
Viewed 0 times
deletabilitymaintainabilitycouplingisolationrefactoring
Problem
Code becomes increasingly hard to change or remove because everything is interconnected. Removing one feature risks breaking others.
Solution
Write code that is easy to delete:
- Feature flags to disable without removing code
- Clear boundaries between modules
- Minimal cross-feature dependencies
- Two similar functions are easier to delete than one shared abstraction
- Wait for the third use case before abstracting
- An abstraction that's wrong is worse than no abstraction
- A depends on B depends on C... is fragile
- Flat dependencies are easier to remove
- Each module should work with minimal imports
- Configuration files are easier to modify than code
- Database rows are easier to delete than code paths
- Feature flags are easier to flip than deploy
- A 50-line file is easy to delete entirely
- A 5000-line file has hidden dependencies everywhere
- Small files = small blast radius
Test: Before writing code, ask 'How hard will it be to remove this in 6 months?'
- Isolation: Each feature/module should be removable independently
- Feature flags to disable without removing code
- Clear boundaries between modules
- Minimal cross-feature dependencies
- Prefer duplication over wrong abstraction:
- Two similar functions are easier to delete than one shared abstraction
- Wait for the third use case before abstracting
- An abstraction that's wrong is worse than no abstraction
- Keep dependency graphs shallow:
- A depends on B depends on C... is fragile
- Flat dependencies are easier to remove
- Each module should work with minimal imports
- Data over code:
- Configuration files are easier to modify than code
- Database rows are easier to delete than code paths
- Feature flags are easier to flip than deploy
- Write small, focused files:
- A 50-line file is easy to delete entirely
- A 5000-line file has hidden dependencies everywhere
- Small files = small blast radius
Test: Before writing code, ask 'How hard will it be to remove this in 6 months?'
Why
The true cost of code is maintenance, not writing. Code that's easy to delete is easy to change, replace, or evolve.
Revisions (0)
No revisions yet.