DEV Community

Cover image for Code Smell 14 - God Objects
Maxi Contieri
Maxi Contieri

Posted on • Updated on • Originally published at maximilianocontieri.com

Code Smell 14 - God Objects

An object that knows too much or does too much.

TL;DR: Don't take too many responsibilities.

Problems

  • Cohesion

  • Coupling

Solutions

  • Split responsibilities.
  • Follow Single Responsibility Principle.
  • Follow The Boy Scout Rule.

Examples

  • Libraries

Exceptions

Sample Code

Wrong