God object

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
(Related design heuristics)
m
Line 16: Line 16:
 
*[[Avoid god classes]]
 
*[[Avoid god classes]]
 
*[[Split large classes]]
 
*[[Split large classes]]
 +
 +
{{Design Anti-patterns}}
 +
[[Category: Anti-Patterns]]

Revision as of 02:25, 22 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.

Related design heuristics


Personal tools