|
In object-oriented programming, a God object is an object that knows too much or does too much. The God object is an example of an anti-pattern. In computer science, object-oriented programming, OOP for short, is a computer programming paradigm. ...
In computer science, anti-patterns are classes of problems that occur frequently in computer programming and that programmers following good practice tend to avoid. ...
The basic idea behind OO programming is that a big problem is broken down into many smaller problems (divide and conquer) and solutions are created for each of them. If you are able to solve all of the small problems, you have solved the big problem as a whole. Therefore there is only one object about which an object needs to know everything: itself. And there is only one problem an object needs to solve: its own. In computer science, divide and conquer (D&C) is an important algorithm design paradigm. ...
Poor code does not follow this approach to creating a solution. Instead, much of a program's overall functionality is coded into a single object. Because this object holds so much data and has so many methods, its role in the program becomes God-like (all-encompassing). Instead of objects communicating amongst themselves directly, the other objects rely on the God object. Because the God object is referenced by so much of the other code, maintenance becomes more difficult than it otherwise would. A God object is the object-oriented analogue of failing to use subroutines in procedural programming languages. In computer science, a subroutine (function, procedure, or subprogram) is a sequence of code which performs a specific task, as part of a larger program, and is grouped as one or more statement blocks; such code is sometimes collected into software libraries. ...
|