gpt4 book ai didi

oop - 依赖/依赖是什么意思?

转载 作者:行者123 更新时间:2023-12-04 14:25:15 27 4
gpt4 key购买 nike

http://tutorials.jenkov.com/ood/understanding-dependencies.html#whatis说(强调我的):

Whenever a class A uses another class or interface B, then A depends on B. A cannot carry out it's work without B, and A cannot be reused without also reusing B. In such a situation the class A is called the "dependant" and the class or interface B is called the "dependency". A dependant depends on its dependencies.



根据谷歌的定义:

a dependent or subordinate thing, especially a country or province controlled by another.



由于 A 依赖于 B,因此依赖项是 A,从属项是 B。这与第一个引用相反。或者我错过了什么?

最佳答案

术语取决于上下文。一般来说,依赖是依赖的同义词,它描述的不是一个实体,而是状态。根据Cambridge dictionary :

一直需要某物或某人的情况,尤其是为了继续存在或运营。

所以它更多地是关于与某事的关系。例如:

A minor child is dependent of his/her parents. The child is in a state of dependency. The dependency describes the relation between the child and its parents.



google 定义只是可用定义之一(例如参见 Collins dictionary),该定义特别适用于地缘政治和房地产领域。例如:

Before 1776, America was a dependency of the British Empire. The dependency America was dependent on the Empire.

He bought a farm with several dependencies



面向对象的术语与更一般的定义没有太大区别:依赖是对象或类之间的关系。这是来自 UML 2.5 标准的更正式的定义:

7.7.1: A Dependency signifies a supplier/client relationship between model elements where the modification of a supplier may impact the client model elements.



因此,重申教程中的内容,我们可以说:

If A has to use B, A depends on B. There is a relation of dependency from A to B. A is said to be the dependent.



出于实际原因和 语言便利 , B 通常被称为依赖(这确实与日常语言相反)。但实际上,依赖关系仍然是A与B的关系。

关于oop - 依赖/依赖是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47001196/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com