God object
From CSSEMediaWiki
(Difference between revisions)
JaninaVoigt (Talk | contribs) (Created page about god object anti pattern) |
JaninaVoigt (Talk | contribs) (→Related design heuristics) |
||
Line 14: | Line 14: | ||
*[[Model the real world]] | *[[Model the real world]] | ||
*[[One key abstraction]] | *[[One key abstraction]] | ||
+ | *[[Avoid god classes]] | ||
+ | *[[Split large classes]] |
Revision as of 03:36, 20 July 2009
God object is an anti pattern that occurs when one class / object is knows or does too much. God objects (or classes) contain a lot of functionality and fulfill more than one responsibility. They should be split up into several objects / classes.
God objects conflict with the object oriented paradigm because they don't really represent a single domain entity but usually consist of a number of different domain concepts all combined into one massive object. Such a practice greatly compromises the maintainability and understandability of code.
Nevertheless, god objects are sometimes used in domains where performance is more important than maintainability, including in hardware and micro controller programming.
Liabilities
- God objects make maintenance very difficult because the god object is referenced so much in other code that making changes to it has widespread effects on the rest of the system.
- God objects make a system harder to understand because the task performed by the object is unclear and there is usually a lot of code in god classes.