Edit on GitHub

God Class

Class Strategy  |  Multi-metric

A class that has accumulated too many responsibilities: it is complex (high WMC), incoherent (low TCC), and data-hungry — reaching into too many other classes to read their data (high ATFD).

Detection Rule

WMC > 47 AND TCC < 0.33 AND ATFD > 5
MetricThresholdMeaning when exceeded
WMC> 47Class has a large total cyclomatic complexity across all methods
TCC< 0.33Less than a third of method pairs share a common field — low cohesion
ATFD> 5More than 5 distinct foreign-class field accesses — class reaches outside itself

What is ATFD?

Access to Foreign Data (ATFD) counts member expressions where the base object is an external identifier (not this or super). Chained access a.b.c counts as one access for a.

// These count toward ATFD:
order.status        // foreign field: order
user.profile.name   // foreign field: user (chained, counts once)
config.timeout      // foreign field: config

// These do NOT count:
this.items.length   // this-based
super.value         // super-based

TypeScript Example

class ApplicationManager {
  // 15 methods (WMC=52) — exceeds 47 ✓
  // TCC=0.12 — methods don't share fields ✓
  // ATFD=9 — reads from user, session, config, db, ... ✓

  processOrder(o: Order) {
    if (o.status === "pending") {
      this.db.save(o);
      this.emailSvc.notify(o.user.email);
      this.analytics.track(o.id);
    }
  }
  // ... 14 more methods of similar reach
}
// 🚨 God Class detected

Remediation

Related strategies

Brain Method · Feature Envy

Related metrics

WMC · TCC · WOC