What is the difference between Composition and Association relationship?

前端 未结 8 1972
眼角桃花
眼角桃花 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:25

    Usually, composition means that the lifetime of the contained object is bounded by that of the container, whereas association is a reference to an object which may exist independently.

    However, this is just the practice I've observed. I hate to admit it, but ploughing through the UML2 spec isn't high on my list of fun stuff to do!

提交回复
热议问题