管理多个类的类是“神对象"吗? [英] Is a class that manages multiple classes a "god object"?

查看:75
本文介绍了管理多个类的类是“神对象"吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

阅读关于上帝对象的维基百科条目,它说一类是知道太多或做太多的神对象.

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?

推荐答案

主要功能/方法可能知道窗口,数据库和其他对象的存在.它可能会执行诸如将模型引入控制器的总体任务.

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.

但这并不意味着它可以管理所有的小细节.它可能对数据库或Windows的实现方式一无所知.

But that doesn't mean it manages all the little details. It probably doesn't know anything about how the database or windows are implemented.

如果这样做,可能会被指控为上帝的物体.

If it did, it could be accused of being a God object.

这篇关于管理多个类的类是“神对象"吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆