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: each speculative abstraction is one more thing a new hire has to learn
- ●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 of one instance a year by team size, from our model at $180K fully-loaded cost per engineer. Low and high use the bottom and top of the Low inputs; mid is halfway. See full methodology.
| Team Size | Low | Mid | High |
|---|---|---|---|
| 3 devs | $700 | $2K | $3K |
| 5 devs | $1K | $3K | $4K |
| 8 devs | $2K | $4K | $6K |
| 10 devs | $2K | $5K | $7K |
| 20 devs | $5K | $9K | $14K |
These are model outputs, not measurements. Every input is on the cost model page, and the same model produces the figures on the 22 smells page. Put in your own team and cost in the smell profile calculator.
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