Tuesday, 17 November 2015

Difference Composition and Aggregation? Define Association, Aggregation, Composition

Composition : Since Engine is part-of Car, relationship between them is  Composition. Here is how they are implemented between Java classes.

Aggregation : Since Organization has Person as employees, relationship between them is Aggregation. Here is how they look like in terms of Java classes

Association: It is a relationship between two objects. In other words, association defines the multiplicity between objects. You may be aware of one-to-one, one-to-many, many-to-one, many-to-many all these words define an association between objects. Aggregation is a special form of association. Composition is a special form of aggregation.

Aggregation: It is a special case of association. A directional association between objects. When an object 'has-a' another object, then you have got an aggregation between them. Direction between them specified which object contains the other object. Aggregation is also called a 'Has-a' relationship.

Composition:It is a special case of aggregation. In a more specific manner, a restricted aggregation is called composition. When an object contains the other object, if the contained object cannot exist without the existence of container object, then it is called composition.

 

No comments:

Post a Comment