Anti-pattern

5th July 2017 at 10:07am

God object

In object-oriented programming, a god object is an object that knows too much or does too much. - Wikipedia

God object 指的是面向对像编程里面,一个类的职责太多,包含的数据太多。这样会使得这个类全知全能,与代码各模块耦合太多,难维护等。

好的策略是使用分治的方法,把类按职责拆分成多个小的类。