Data Clumps: What It Costs and How to Fix It
Groups of data items that repeatedly appear together across multiple classes or method signatures.
What It Is
Data Clumps occur when the same group of variables (for example, street, city, state, ZIP code) appear together in multiple classes, method signatures, or data structures. Each location maintains its own copy of the grouping logic, and any change to the group's structure must be replicated everywhere. The clump should be a first-class object, but instead it exists as a scattered pattern that developers must recognize and maintain by convention.
Why It Costs Money
Changes to the data group propagate to every location where the clump appears. Adding a country field to an address that exists as 4 separate parameters in 20 functions requires updating all 20 functions and their callers.
Validation inconsistency creeps in over time. Each location that handles the clump may validate the data slightly differently, leading to subtle bugs where data passes through one path but fails in another.
The missing abstraction prevents useful behaviour. An Address object can calculate shipping zones, validate formats, and format for display. Four separate strings cannot.
Specific Cost Mechanisms
- ●Change propagation: each structural change to the clump requires updating every place it appears
- ●Validation inconsistency: different validation rules at different sites cause intermittent bugs
- ●Missing encapsulation: behaviour that belongs to the concept is scattered across consuming code
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 Medium inputs; mid is halfway. See full methodology.
| Team Size | Low | Mid | High |
|---|---|---|---|
| 3 devs | $2K | $4K | $5K |
| 5 devs | $3K | $5K | $8K |
| 8 devs | $4K | $8K | $12K |
| 10 devs | $5K | $10K | $15K |
| 20 devs | $9K | $19K | $28K |
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.
Repeated parameter groups across methods
Detects repeated parameter patterns
Indirect detection through parameter count
Built-in inspection that detects repeated field groups
Refactoring Patterns
Proven techniques to eliminate this smell. See all refactoring patterns.
Extract Class
The same group of fields appears in multiple classes
Introduce Parameter Object
The same group of parameters appears in multiple method signatures
Preserve Whole Object
Callers destructure an object only to pass its fields individually