DispensablesLow

Lazy Class: What It Costs and How to Fix It

A class that does too little to justify its existence, adding complexity without proportionate value.

Annual Cost$800 - $6k
Severity
2/5
CategoryDispensables
Detection4 tools

What It Is

A Lazy Class is a class that was created with good intentions (perhaps during an earlier refactoring or in anticipation of future needs) but does not carry enough behaviour or data to justify its existence. It might be a wrapper around a single method, a data class with no behaviour, or a class that was trimmed down during refactoring until only a shell remained. Every class has a maintenance cost: it must be understood, documented, tested, and navigated past. If the class does not earn its keep, that cost is pure waste.

Threshold: Classes with fewer than 3 methods and fewer than 20 lines that are not data transfer objects warrant review. If the class can be described as 'a wrapper around X,' it is probably lazy.

Why It Costs Money

1

Navigation overhead. Every extra class is one more file to open, one more import to manage, and one more name to remember. In IDEs with 'find references' and 'go to definition,' lazy classes add unnecessary hops.

2

Conceptual weight. Each class represents a concept that developers must understand. A lazy class that wraps a single method forces developers to understand the wrapper's purpose (is it for testing? extensibility? legacy reasons?) before they can understand the code that uses it.

3

Maintenance cost is real even when the class does nothing meaningful. When the underlying concept changes, the lazy class must be updated even though it adds no value.

Specific Cost Mechanisms

  • Navigation overhead: 5-10 minutes per developer per week spent navigating through unnecessary abstractions
  • Conceptual confusion: new developers spend time understanding why the class exists
  • Maintenance drag: each refactoring must account for the lazy class even when it adds no value

Estimated Annual Cost

Cost per instance by team size and codebase size. Based on $120,000 average developer salary. See full methodology.

Team SizeSmall (<50k LOC)Medium (50k-200k)Large (200k+)
3 devs$800$1,800$3,600
5 devs$1,300$3,000$6,000
10 devs$2,000$4,500$6,000
20 devs$2,600$6,000$6,000

How to Detect It

Specific rules and thresholds for automated detection. See full tool comparison.

SonarQube
squid:S1609 / squid:S2094

Empty class body, single abstract method

CodeClimate
method-count / file-lines

Classes with < 3 methods or < 20 lines

PMD
EmptyMethodInAbstractClassShouldBeAbstract

Abstract classes with empty method bodies

Manual
Inline class candidate analysis

Classes referenced in only 1-2 locations

Refactoring Patterns

Proven techniques to eliminate this smell. See all refactoring patterns.

Inline Class

The class has one caller and adds no independent value

Effort: 30-60 minutes
Impact: Removes one navigation hop and one concept to understand

Collapse Hierarchy

A subclass adds nothing to its parent

Effort: 1-2 hours
Impact: Simplifies the inheritance tree

Merge Module

A module contains only one or two trivial classes

Effort: 30-90 minutes
Impact: Reduces file count and navigation complexity

Related Smells