God Class: What It Costs and How to Fix It
A class that knows too much and does too much, concentrating responsibilities that should be distributed.
What It Is
A God Class (also called Large Class or Blob) is a class that has accumulated so many fields, methods, and responsibilities that it becomes the gravitational centre of the codebase. Everything depends on it, everyone modifies it, and nobody fully understands it. God Classes typically start as reasonable domain objects that grow incrementally over months or years. Each addition seems small, but the cumulative effect creates a class that violates the Single Responsibility Principle so thoroughly that it becomes a bottleneck for the entire team.
Why It Costs Money
Merge conflicts become more likely. When developers working on unrelated features all have to edit the same large class, their changes collide in the same file. Every hour spent resolving those conflicts is an hour not spent on the feature.
Onboarding slows down. New developers take longer to become productive in modules dominated by god classes, because they must understand the entire class before they can safely change any part of it.
Bug clustering is severe. Defects concentrate heavily in a small fraction of the codebase: CodeScene's hotspot research reports cases where roughly 1.2% of the code accounts for around 45% of the bugs teams detect and fix. God Classes, being large and modified constantly, are almost always among those hotspots, making them a leading source of production incidents.
Specific Cost Mechanisms
- ●Merge conflict resolution: whenever two features in flight both have to change the god class
- ●Onboarding delay: additional ramp time per new hire, at fully-loaded cost (our model assumes 1 to 3 weeks)
- ●Bug investigation: god class bugs are slow to diagnose because the class has so many interacting state variables
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 Critical inputs; mid is halfway. See full methodology.
| Team Size | Low | Mid | High |
|---|---|---|---|
| 3 devs | $7K | $16K | $25K |
| 5 devs | $11K | $25K | $40K |
| 8 devs | $17K | $39K | $61K |
| 10 devs | $21K | $48K | $75K |
| 20 devs | $41K | $94K | $146K |
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.
Class coupling > 20, class lines > 750
File lines > 250, method count > 20
Set file max to 300 lines for JS/TS
Detects classes with high WMC (Weighted Methods per Class)
Refactoring Patterns
Proven techniques to eliminate this smell. See all refactoring patterns.
Extract Class
Groups of fields and methods that form a coherent subset of the class responsibilities
Extract Subclass
Some instances use only a subset of the class features
Replace Data Value with Object
Primitive fields that carry behaviour elsewhere in the god class