DEV Community

loading...
Cover image for Code Smell 14 - God Objects

Code Smell 14 - God Objects

mcsee profile image Maxi Contieri Originally published at mcsee.Medium Updated on ・1 min read

An object that knows too much or does too much.

Problems

Solutions

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

Examples

  • Libraries

Exceptions

Sample Code

Wrong

Right

Detection

Linters can count methods and warn against a threshold.

Tags

  • Cohesive

Conclusion

Libraries were fine in the 60. In Object Oriented Programming we will distribute responsibilities among many objects.

Also Known as

  • Large Class

More info

Credits

Photo by Francisco Ghisletti on Unsplash

Discussion (0)

pic
Editor guide