Which is an anti-pattern known as the "God object" (or God class)?
Options
- A class that knows and does too much and is used by everything (Correct option)
- A class with one clear and well-defined single purpose
- A class that only contains static methods and no fields
- 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.