What is a god object in OOP

linkCatch


A God object (English God object) or God class (English god class) in object-oriented programming refers to an object that “knows too much” or “does too much”. The God object is an example of an anti-pattern.

The basic idea of ​​structured programming is that large problems are broken down into a large number of smaller problems in order to find solutions for each of them. Solving the small problems means, as it were, solving the big problem. Therefore, each object only needs to have oneself really know everything, less about others; likewise it only has to solve its own problem, not that of the other objects.

Codes based on God objects do not follow this paradigm. Instead, a large part of the functionality of a program is stored in a single object. Because this object contains so much data and methods, its meaning within the program becomes almost all-encompassing (god-like).

The individual objects do not communicate directly with each other, but are dependent on the one God object. Since the God object is so heavily referenced with the rest of the code, the maintenance of the program or the object becomes very difficult.

The use of a God object within object-oriented programming thus systematically corresponds to the poor use of subroutines or the excessive use of global variables in procedural programming.

While a God-object is generally considered to be a characteristic of a weak program structure, it is common practice within limited environments such as the microcontroller, where fast performance is more important than maintenance. However, since microcontrollers are also becoming more and more powerful, this argument is likely to become less and less important.

Big hairy object


A similar, often used synonymously, slang term is des Big hairy object. The main difference is that the Big hairy object, in contrast to the God object, does not take control of the program, but merely represents an overloaded interface.

literature


  • Arthur J. Riel: Object-Oriented Design Heuristics. Addison-Wesley, Boston, MA 1996, ISBN 0-201-63385-X, 3: Topologies of Action-Oriented Vs. Object-Oriented Applications (3.2: Do not create god classes / objects in your system. Be very suspicious of an abstraction whose name contains Driver, Manager, System, or Subsystem.).

Web links











Categories:Object-oriented programming | Anti-Pattern




Status of information: 02/22/2021 7:25:18 AM CET

Source: Wikipedia (authors [version history]) License: CC-BY-SA-3.0

Changes: All images and most of the design elements associated with them have been removed. Some of the icons have been replaced by FontAwesome icons. Some templates have been removed (such as "Article worth reading", "Excellent article") or rewritten. Most of the CSS classes have been removed or standardized.
Wikipedia-specific links that do not lead to articles or categories (such as "Redlink", "Edit links", "Portal links") have been removed. All external links have an additional FontAwesome icon. In addition to other small design adjustments, media containers, maps, navigation boxes, spoken versions and geo-microformats have been removed.

Important NOTE Since the given content was automatically taken over from Wikipedia at the specified time, manual checking was and is not possible. LinkFang.org therefore does not guarantee the correctness and topicality of the content taken over. If the information is incorrect in the meantime or there are errors in the presentation, we ask you to contact us by: E-Mail.
Also note:Imprint & privacy policy.