英文groups是什么意思(英语单词AssociationAggregation)

Association is a relationship between two objects, but the relationship between them could be multiple types. It could be one-to-one, one-to-many, many-to-one, many-to-many. In other words, the relationship is very flexible(灵活的) and loose(松散的).

In software programming, an object may use functions provided by an object of another class, this kind of relationship is called association.

英文groups是什么意思(英语单词AssociationAggregation)(1)

Aggregation and Composition are subsets of association.

Aggregation is a subset(子集) of association. It depicts(描述) a directional(有方向的) association between two objects, which means it is an association that represents(代表) a part-whole or part-of relationship. But this relationship is not too restrictive, which means two objects can exist without each other.

英文groups是什么意思(英语单词AssociationAggregation)(2)

Composition is a subset of aggregation. This relationship is most restrictive(严苛的), which means it represents an ownership(拥有) relationship. The contained(被包含的) object cannot exist without the existence(存在) of container(容器、拥有者) object.

英文groups是什么意思(英语单词AssociationAggregation)(3)

Example:

The relationship between Car and its Engine is called Composition. Because its Engine cannot be used in any other car.

汽车与专属的发动机之间的关系是Composition。因为发动机离开汽车后,将没有单独存在的意义。

The relationship between Classroom and Students is called Aggregation. Because each one can still exist without each other.

教室与学生之间的关系是Aggregation。因为一个教室可以包含多个学生,并且两者都可以独立存在。(估计大家会觉得一个学生也可以在多个教室上课,所以不是Aggregation。这个确实不同的角度分析有不同的看法。但我个人更认为是Aggregation,因为学生不能包含教室)

,

免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com

    分享
    投诉
    首页