UML aggregation vs association

后端 未结 8 2361
無奈伤痛
無奈伤痛 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:35

    I tend to use Aggregation to show a relation that is the same as a Composition with one big distinction: the containing class is NOT responsible for the life-cycle of the contained object. Typically, a (non-null) pointer or reference to the object-to-be-contained is passed to the containing class's constructor. The containing object, for the duration of its life-cycle, depends upon the contained object existing. The containing object cannot do its job (fully) without the contained object. This is my interpretation of the "Part/Whole" relationship implied by Aggregation.

提交回复
热议问题