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 routine. When a 2,000-line class is modified by 3-4 developers simultaneously, merge conflicts occur on nearly every sprint. Teams with god classes report spending 2-5 hours per developer per week resolving merge conflicts in these files alone.
Onboarding delay increases sharply. New developers need 2-3 additional weeks 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. Research shows that 60% of production bugs originate in the top 5% largest classes. God Classes are almost always in that top 5%, making them the single largest source of production incidents.
Specific Cost Mechanisms
- ●Merge conflict resolution: 2-5 hours per developer per week when actively developing features that touch the god class
- ●Onboarding delay: 2-3 weeks of additional ramp time per new hire, at fully-loaded salary cost
- ●Bug investigation: god class bugs take 2-3x longer to diagnose because the class has so many interacting state variables
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 | $8,000 | $18,000 | $36,000 |
| 5 devs | $14,000 | $30,000 | $50,000 |
| 10 devs | $22,000 | $42,000 | $62,000 |
| 20 devs | $30,000 | $55,000 | $62,000 |
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