What is the difference between Composition and Association relationship?

前端 未结 8 1971
眼角桃花
眼角桃花 2020-12-01 04:05

In OOP, what is the difference between composition (denoted by filled diamond in UML) and association (denoted by empty diamond in UML) relationship between classes. I\'m a

8条回答
  •  温柔的废话
    2020-12-01 04:29

    Composition means a part of the entity state is encapsulated by another type but it is conceptualy part of the entity state. For example you may have a address type and a employee entity type that includes a address.

    Association means that a entity type is assocciated with another entity type but the assocciated entity is conceptualy not part of the entity state. For example a employee may be assocciated with a company.

提交回复
热议问题