UML aggregation vs association

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

    This term often gets confused.

    Aggregation and composition are some of the types of association. There is hardly a difference between aggregations and associations during implementation, and many will skip aggregation relations altogether in their diagrams with association relation.

    You can get the idea from this analogy.

    Class:A(person) and Class:B(car) has association relation, if Class:A has a Class:B declaration, and also Class:B(car) object is not essential to create a Class:A(person) object.

    Class:A(car) and Class:B(tyre) has aggregation relation, if Class:A has a Class:B declaration, and also Class:B(tyre) object is essential to create a Class:A(car) object.

    Cheers!

提交回复
热议问题