摘自: sangmado - UML中关联(Association)、聚合(Aggregation)和合成(Composition)之间的区别
A 和 B 相互调用和访问对方的元素。
A and B call and access each other’s elements.
A 中拥有一个 B,但 B 脱离于 A 仍然可以独立存活。
A has a B, and B can outlive A.
A "uses" B = Aggregation : B exists independently (conceptually) from A.
A 中拥有一个 B,B 脱离 A 后在系统中没有任何存活的意义。
A has a B, and B depends on A.
A "owns" B = Composition : B has no meaning or purpose in the system without A.
我们可以从不同的角度来理解和区分这三种关系:
Single owner
Have their own lifetime
Owner's lifetime
Child objects belong to a single parent
Child objects belong to single parent
所以,总结来说,聚合(Aggregation)是一种特殊的关联(Association),合成(Composition)是一种特殊的聚合(Aggregation)。
Association->Aggregation->Composition
本文来自博客园,作者:泥烟,CSDN同名, 转载请注明原文链接:https://www.cnblogs.com/Knight02/p/17489931.html