网站首页  英汉词典

请输入您要查询的英文单词:

 

单词 God class
释义

God class

中文百科

上帝对象 God object

(重定向自God class)

在面向对象编程领域, 一个上帝对象(God object)是一个了解过多或者负责过多的对象。 上帝对象是反面模式的一个例子。

结构化编程背后的基本概念是一个大型的问题应该被分解成为多个较小的问题中(分而治的策略)并且针对每个较小的问题提出解决方案。当每个小问题都得到解决后,大问题本体就得到了解决。因此对象应该知道的一切就是它本身。类似的,对象应该解决的问题是它所属的问题。

基于上帝对象编写的代码并不遵从上述的方式。取而代之的是进程的整体功能都被编程到一个单一的"了解全部"的对象当中,这个对象维护了整个进程的大部分信息并且提供了操作数据的大部分方法。所以这个对象持有过多的数据以及负责过多的方法,它在进程中的角色就如同上帝一般。不同于编写直接在彼此之间进行交互的对象,其他进程中的对象都依赖于这个上帝对象获得信息以及交互。由于上帝对象被过多的其他代码所引用,相比一个进行了均匀切分的进程而言维护变得更加的困难。

英语百科

God object 上帝对象

(重定向自God class)

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.

A common programming technique is to separate a large problem into several smaller problems (a divide and conquer strategy) and create solutions for each of them. Once the smaller problems are solved, the big problem as a whole has been solved. Therefore a given object for a small problem need only know about itself. Likewise, there is only one set of problems an object needs to solve: its own problems.

随便看

 

英汉网英语在线翻译词典收录了3779314条英语词汇在线翻译词条,基本涵盖了全部常用英语词汇的中英文双语翻译及用法,是英语学习的有利工具。

 

Copyright © 2004-2024 encnc.com All Rights Reserved
更新时间:2025/6/20 9:58:39