Avoid god classes
From CSSEMediaWiki
(Difference between revisions)
(add avoid god class) |
(adding more relevant links) |
||
Line 6: | Line 6: | ||
== Relevant Links == | == Relevant Links == | ||
+ | * [[Single responsibility principle]] | ||
* [[Separation of concerns]] | * [[Separation of concerns]] | ||
* [[Model the real world]] | * [[Model the real world]] | ||
* [[Tell, don't ask]] | * [[Tell, don't ask]] |
Revision as of 03:57, 6 October 2008
A god class is a class that either know too much or does too much; a class that have to deal with too many responsibilities. The instantiated object of a god class is called a god object.
Instead of having objects collaborate and distribute data among themselves, they rely to the god object as a "centralised data center". As a consequence of this, maintenance can become difficult. The god class usually has too many number of irrelevant functions or too many global variables.
However, there is an instance in which a god class is particularly useful, where performance is needed over maintainability (eg. micro-controllers or hardware programming)