Association is a term used to define two related classes in Object oriented Environment.
Aggregation and Composition defines how the two classes are related.
Aggregation - Aggregation says that two classes are related but each individual class has its own existence. For Example : School and Student, these two classes are interrelated, School has Students and Student belongs to a School. But if the School is closed that does not implies that a Student does not exist. The Student can join other School.
Aggregation is mentioned as a hollow diamond ending arrow in UML - class diagram.
Composition - Composition defines a "Has a" relationship between two classes. Common example of composition is Human and Human heart. If Human dies then the heart will die certainly.
Composition is mentioned as a filled diamond ending arrow in UML - class diagram.
Note: In the above diagrams the diamond should be towards Contained class. i.e Car as engine so the diamond should be close to Car.
Aggregation and Composition defines how the two classes are related.
Aggregation - Aggregation says that two classes are related but each individual class has its own existence. For Example : School and Student, these two classes are interrelated, School has Students and Student belongs to a School. But if the School is closed that does not implies that a Student does not exist. The Student can join other School.
Aggregation is mentioned as a hollow diamond ending arrow in UML - class diagram.
Composition - Composition defines a "Has a" relationship between two classes. Common example of composition is Human and Human heart. If Human dies then the heart will die certainly.
Composition is mentioned as a filled diamond ending arrow in UML - class diagram.
Note: In the above diagrams the diamond should be towards Contained class. i.e Car as engine so the diamond should be close to Car.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.