Repaso
EspaƱol

Which is an anti-pattern known as the "God object" (or God class)?

Options

  1. A class that knows and does too much and is used by everything (Correct option)
  2. A class with one clear and well-defined single purpose
  3. A class that only contains static methods and no fields
  4. An immutable class whose state is never changed after creation

Answer

A class that knows and does too much and is used by everything

Why

A God object concentrates many responsibilities: data access, business rules, formatting and more. It becomes huge, hard to test and every change risks breaking something.

Cure: split it by responsibility (Single Responsibility Principle) into smaller cohesive classes.

Other anti-patterns: spaghetti code (tangled flow), copy-paste programming, golden hammer (using one tool for everything), premature optimization.

Remember

God object = one class doing everything. Split by responsibility.

Key terms

Practice this question in Repaso