UML aggregation vs association

后端 未结 8 2373
無奈伤痛
無奈伤痛 2020-11-28 04:48

Here I am, with another question about aggregation and association. I wanted to learn some basics of UML, so I started reading \"UML distilled\" by Martin Fowler. I read bot

8条回答
  •  日久生厌
    2020-11-28 05:20

    Implementation wise there is not much of a difference but conceptually there is big difference: aggregations are used to express a hierarchy. When you work with a hierarchy of components there are certain type of operations you need to have in the root interface:

    • find subcomponents in the hierarchy
    • add/remove subcomponents to/from the hierarchy
    • change common attributes of all components
    • traverse the hierarchy recursively (Visitor pattern)
    • reconfigure the hierarchy and the links (associations) between the components

    Most of these operations are not needed when dealing with associations.

提交回复
热议问题