god-object

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

孤街醉人 提交于 2019-12-22 05:37:08
问题 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 class evil? When you use the class, you always call a single method like: MyClass::coolMethod(); and then you leave it alone altogether so it feels that it would be stupid to make it constructable? There's really not much point in constructing

Fat models and skinny controllers sounds like creating God models [closed]

做~自己de王妃 提交于 2019-12-17 14:59:07
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . 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

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

那年仲夏 提交于 2019-12-10 14:55:23
问题 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. For some kind of points it will be just printing them on the screen as they are, others can be ignored, others added, so there is some kind of logic associated to them that can get complex. How to actually draw the graphic is not the main issue here

Is a class that manages multiple classes a “god object”?

邮差的信 提交于 2019-12-10 01:14:16
问题 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 class for connecting window management, DB connections, etc? 回答1: The main function/method may know about the existence of the windows, databases, and other objects. It may perform over-arching tasks like introduce the model to the controller. But

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

十年热恋 提交于 2019-12-05 08:01:50
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 class evil? When you use the class, you always call a single method like: MyClass::coolMethod(); and then you leave it alone altogether so it feels that it would be stupid to make it constructable? There's really not much point in constructing objects out of it, because it is more like a tool that contains a few methods that you can just call

God object - decrease coupling to a 'master' object

試著忘記壹切 提交于 2019-12-04 20:43:16
问题 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 bad idea, beacuse I can't easily see what a method needs to function, or even what might happen if with a certain combination of parameters for module Y which is totally unrelated to my current module. What are some good techniques for decreasing

How do you refactor a God class?

跟風遠走 提交于 2019-11-27 21:16:49
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. It's like Jenga. You will need patience and a steady hand, otherwise you have to recreate everything from scratch. Which is not bad, per se - sometimes one needs to throw away code. Other advice: Think before pulling out methods: on what data does this method operate? What responsibility does it have? Try to maintain the interface of the god class at first

Fat models and skinny controllers sounds like creating God models [closed]

二次信任 提交于 2019-11-27 16:38:05
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 call the corresponding method on the model and then bring up the view. So I've two concerns here which I don't understand: The controller and router are really not doing much different tasks other than just calling a method on the God-like model based on the route. Models are doing too much. Sending emails, creating relationships, deleting and

How do you refactor a God class?

家住魔仙堡 提交于 2019-11-26 20:39:24
问题 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. 回答1: It's like Jenga. You will need patience and a steady hand, otherwise you have to recreate everything from scratch. Which is not bad, per se - sometimes one needs to throw away code. Other advice: Think before pulling out methods: on what data does this