摘自: sangmado - UML中关联(Association)、聚合(Aggregation)和合成(Composition)之间的区别 元素名称 符号图例 含义 Association A 和 B 相互调用和访问对方的元素。 A and B call and access each other’s elements. Aggregation A 中拥有一个 B,但 B 脱离于 A 仍然可以独立存活。 A has a B, and B can outlive A. A "uses" B = Aggregation : B exists independently (conceptually) from A. Composition 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. 我们可以从不同的角度来理解和区分这三种关系: Association Aggregation Composition Owner No owner Single owner Single owner Lifetime Have their own lifetime Have their own lifetime Owner's lifetime Child Object Child objects all are independent Child objects belong to a single parent Child objects belong to single parent 所以,总结来说,聚合(Aggregation)是一种特殊的关联(Association),合成(Composition)是一种特殊的聚合(Aggregation)。 Association->Aggregation->Composition 本栏目推荐文章实验1:UML与面向对象程序设计原则UML 类图 六种关系UML中类之间的六大关系设计模式和UML基础信息UML 用例关系(包含、扩展、泛化)与 UML类图关系(依赖、关联、聚合、组合、泛化)UML时序图UML类图uml类图UML类图关系Linux下自动生成c++工程的UML类图