... | @@ -4,17 +4,22 @@ |
... | @@ -4,17 +4,22 @@ |
|
An Association classifies a set of tuples representing links between typed instances, e.g., two instances of classes at runtime.
|
|
An Association classifies a set of tuples representing links between typed instances, e.g., two instances of classes at runtime.
|
|
|
|
|
|
## Example
|
|
## Example
|
|

|
|

|
|
|
|
|
|
# Aggregation vs Composition
|
|
|
|
|
|
|
|
|
|
# Aggregation and Composition
|
|
Aggregation and Composition are subsets of associations meaning they are specific cases of association.
|
|
Aggregation and Composition are subsets of associations 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:
|
|
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: Lecture (parent) and Student (child). Delete the Lectureand the Students still exist.
|
|
## Aggregation
|
|
|
|
Aggregation implies a relationship where the child can exist independently of the parent. Example: Lecture (parent) and Student (child). Delete the Lectureand 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.
|
|
### Example
|
|
|
|

|
|
|
|
|
|
## Example
|
|
## Composition
|
|
|
|
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.
|
|
|
|
|
|
|
|
### Example
|
|

|
|

|
|
|
|
|
|
|
|
The example contains a class person (parent) with the (child) classes head, leg, and heart. |
|
|
|
\ No newline at end of file |