... | @@ -11,13 +11,17 @@ Aggregation and Composition are subsets of associations, i.e., they are specific |
... | @@ -11,13 +11,17 @@ Aggregation and Composition are subsets of associations, i.e., they are specific |
|
In both aggregation and composition object of one class "owns" object of another class. But there is a small difference.
|
|
In both aggregation and composition object of one class "owns" object of another class. But there is a small difference.
|
|
|
|
|
|
## Aggregation
|
|
## Aggregation
|
|
Aggregation implies a relationship where the child can exist independently of the parent. Example: Lecture (parent) and Student (child). Delete the Lecture and the Students still exist.
|
|
Aggregation implies a relationship where the child can exist independently of the parent.
|
|
|
|
|
|
### Example
|
|
### Example
|
|

|
|

|
|
|
|
|
|
|
|
Lecture (parent) and Student (child). Delete the Lecture and the Students still exist.
|
|
|
|
|
|
## Composition
|
|
## Composition
|
|
Composition implies a relationship where the child cannot exist independent of the parent. Example: Person (parent) and Head, Leg, and Heart (children). The children don't exist separate to a Person.
|
|
Composition implies a relationship where the child cannot exist independent of the parent.
|
|
|
|
|
|
### Example
|
|
### Example
|
|

|
|

|
|
|
|
|
|
|
|
Person (parent) and Head, Leg, and Heart (children). The children don't exist separate to a Person. |
|
|
|
\ No newline at end of file |