Association vs Aggregation vs Composition 잘~ 비교 설명한 글(펌)
by 지금당장해Association vs Aggregation vs Composition
The question "What is the difference between association, aggregation and composition" has been frequently asked lately.
Actually, Aggregation and Composition are subsets of association meaning they are specific cases of association. In both aggregation and composition object of one class "owns" object of another class. But there is a subtle difference:
- Aggregation implies a relationship where the child can exist independently of the parent. Example: Class (parent) and Student (child). Delete the Class and the Students still exist.
- Composition implies a relationship where the child cannot exist independent of the parent. Example: House (parent) and Room (child). Rooms don't exist separate to a House.
Composition Example:
We should be more specific and use the composition link in cases where in addition to the part-of relationship between Class A and Class B - there's a strong lifecycle dependency between the two, meaning that when Class A is deleted then Class B is also deleted as a result
Aggregation Example:
It's important to note that the aggregation link doesn't state in any way that Class A owns Class B nor that there's a parent-child relationship (when parent deleted all its child's are being deleted as a result) between the two. Actually, quite the opposite! The aggregation link is usually used to stress the point that Class A instance is not the exclusive container of Class B instance, as in fact the same Class B instance has another container/s.
https://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-aggregation-vs-composition/
'내가 하는일' 카테고리의 다른 글
[펌]Web server와 WAS의 정의 (0) | 2018.07.12 |
---|
블로그의 정보
지금 당장 해!!!
지금당장해