Speculative Generality: What It Costs and How to Fix It
Abstractions, parameters, and classes created for anticipated future needs that never materialised.
What It Is
Speculative Generality occurs when developers create abstractions, interfaces, parameters, or entire class hierarchies 'in case we need them later.' The anticipated use case never arrives, but the abstraction remains, adding complexity that every future developer must understand. Common manifestations include: abstract classes with only one subclass, interfaces implemented by only one class, unused parameters passed through 'for future extensibility,' and factory patterns wrapping a single concrete class.
Why It Costs Money
Every unnecessary abstraction is a concept that developers must understand. When a developer encounters an interface with one implementor, they must figure out whether there is a reason for the interface or whether it is speculative. This investigation wastes 15-30 minutes per encounter.
Speculative abstractions make the correct change path unclear. Should the developer modify the interface, the implementation, or add a new implementation? The abstraction suggests that extension is the intended approach, even when modification is simpler.
Testing overhead increases. Abstract factories, strategy patterns, and interface hierarchies require more test infrastructure than direct implementations, even when only one variant exists.
Specific Cost Mechanisms
- ●Comprehension overhead: 15-30 minutes per developer per speculative abstraction during onboarding
- ●Decision paralysis: developers unsure whether to extend or modify the speculative structure
- ●Test infrastructure: unnecessary mocks and test doubles for single-implementation interfaces
Estimated Annual Cost
Cost per instance by team size and codebase size. Based on $120,000 average developer salary. See full methodology.
| Team Size | Small (<50k LOC) | Medium (50k-200k) | Large (200k+) |
|---|---|---|---|
| 3 devs | $1,000 | $2,100 | $4,200 |
| 5 devs | $1,600 | $3,500 | $7,000 |
| 10 devs | $2,500 | $5,250 | $7,000 |
| 20 devs | $3,200 | $7,000 | $7,000 |
How to Detect It
Specific rules and thresholds for automated detection. See full tool comparison.
Abstract class without abstract methods, functional interface with one use
Small classes/interfaces with single implementations
Unused abstractions and parameters
Directly detects single-implementation interfaces
Refactoring Patterns
Proven techniques to eliminate this smell. See all refactoring patterns.
Collapse Hierarchy
An abstract class has only one concrete subclass
Inline Class
An interface has only one implementation and no test double
Remove Parameter
A parameter is passed through but never used