Questions tagged [god-object]

God object is an object that knows too much or does too much. The god object is an example of an anti-pattern.

A God object is an object that knows too much or does too much. The God object is an example of an .

From Wiktionary: (programming, object-oriented) a poorly designed object that does more than one thing. (In other words, it is an object that violates the single responsibility principle of SOLID.)

Wiktionary: https://en.wiktionary.org/wiki/God_object

28 questions
107
votes
3 answers

Fat models and skinny controllers sounds like creating God models

I've been reading a lot of blogs which advocate the fat models and skinny controllers approach, esp. the Rails camp. As a result the routers is basically just figuring out what method to call on what controller and all the controller method does is…
28
votes
4 answers

How do you refactor a God class?

Does anyone know the best way to refactor a God-object? Its not as simple as breaking it into a number of smaller classes, because there is a high method coupling. If I pull out one method, i usually end up pulling every other method out.
Oliver Watkins
  • 12,575
  • 33
  • 119
  • 225
17
votes
4 answers

God Controllers - How to prevent them?

In a few MVC projects I've been working on, it has become apparent that there are a few problematic controllers that have organically grown into God classes - demi-gods each in their own domain, if you will. This question might be more of a matter…
MunkiPhD
  • 3,636
  • 1
  • 29
  • 51
13
votes
4 answers

Is a class that manages multiple classes a "god object"?

Reading the wikipedia entry about God Objects, it says that a class is a god object when it knows too much or does too much. I see the logic behind this, but if it's true, then how do you couple every different class? Don't you always use a master…
Daniel Sorichetti
  • 1,921
  • 1
  • 20
  • 34
12
votes
7 answers

Dealing with god objects

I work in a medium sized team and I run into these painfully large class files on a regular basis. My first tendency is to go at them with a knife, but that usually just makes matters worse and puts me into a bad state of mind. For example, imagine…
Ty.
  • 3,888
  • 3
  • 24
  • 31
11
votes
2 answers

When to use nested controllers instead of services in angularjs?

I just started to use AngularJS, so I'm not an expert. I have a div that represent the right area of my html view. In that div I have a controller, i.e.
...
Inside that div I have…
Miguel A. Carrasco
  • 1,379
  • 1
  • 15
  • 26
9
votes
4 answers

How can I write a Controller without making it a God object?

In my app I have a Controller that's started by the main method. The controller initializes hooks, database connections, the UI, another connection, and other things. It holds most of the state of the program (no, its not a Singleton). In another…
TheLQ
  • 14,830
  • 14
  • 69
  • 107
8
votes
5 answers

MVVM and avoiding Monolithic God object

I am in the completion stage of a large project that has several large components: image acquisition, image processing, data storage, factory I/O (automation project) and several others. Each of these components is reasonably independent, but for…
bufferz
  • 3,400
  • 5
  • 24
  • 37
8
votes
6 answers

God object - decrease coupling to a 'master' object

I have an object called Parameters that gets tossed from method to method down and up the call tree, across package boundaries. It has about fifty state variables. Each method might use one or two variables to control its output. I think this is a…
Andrei Tanasescu
  • 638
  • 1
  • 7
  • 15
7
votes
1 answer

Interface inheritance to breakup god objects?

I work on a fairly large product. It's been in development since .Net 1.0 was still a work-in-progress and so it has a lot of bad quality code and was not written with unit tests in mind. Now we're trying to improve the quality and implement tests…
Earlz
  • 62,085
  • 98
  • 303
  • 499
6
votes
5 answers

I have a class with 14 static methods and 4 static properties - is that bad?

I have been writing a PHP class that is exactly 450 lines long and it contains 14 static methods and 4 static properties as well as 6 constants (and private __construct() and __clone()). I am wondering here is that am I doing something wrong, is my…
Tower
  • 98,741
  • 129
  • 357
  • 507
6
votes
4 answers

Which is more evil: an unnecessary singleton or a God Object?

Here's the situation: I've got a class that is doing too much. It's mainly for accessing configuration information, but it also has the database connection. It's implemented as a singleton, so this also makes unit testing it difficult as most…
Jason Baker
  • 192,085
  • 135
  • 376
  • 510
5
votes
2 answers

Pulling dependencies out of "god" objects in a DI framework

I have a Servlet that has a lot of existing code. I'm trying to add dependency injection into one part of it. Currently I am doing it manually: public class AdjustBookPriceHandler extends BookRequestHandler { @Override public void…
ICR
  • 13,896
  • 4
  • 50
  • 78
5
votes
2 answers

Designing a class in such a way that it doesn't become a "God object"

I'm designing an application that will allow me to draw some functions on a graphic. Each function will be drawn from a set of points that I will pass to this graphic class. There are different kinds of points, all inheriting from a MyPoint class.…
devoured elysium
  • 101,373
  • 131
  • 340
  • 557
4
votes
4 answers

Categories or Partial Classes: Pattern to Resolve "God Object" Code Smell?

A class is too large and becomes unwieldy to work with. In Objective-C I'd be tempted to use Categories to break the class up, but then: wouldn't categories just be dividing a house full of too much junk into rooms? The same question applies to…
Dan Rosenstark
  • 68,471
  • 58
  • 283
  • 421
1
2