Explain Association, Aggregation, Composition, Generalization and Realization.

Association
Association is a relationship between two objects. In other words, association defines the multiplicity between objects. Both Composition and Aggregation are the form of association between two objects, but there is a subtle difference between composition and aggregation.

Composition
We refer association between two objects as Composition, when one class owns other class and other class cannot meaningfully exist, when its owner destroyed
Example: Human class is a composition of several body parts including Hand, Leg and Heart. When human object dies, all its body part ceased to exist meaningfully.


Aggregation
In the case of Aggregation, including object can exists without being part of the main object.
Example: A Player which is part of a Team, can exist without a team and can become part of other teams as well.


Generalization
Generalization uses a “is-a” relationship from a specialization to the generalization class. Common structure and behaviour are used from the specialization to the generalized class. At a very broader level you can understand this as inheritance. Why I take the term inheritance is, you can relate this term very well. Generalization is also called a “Is-a” relationship.
Example: Consider there exists a class named Person. A student is a person. A faculty is a person. Therefore, here the relationship between student and person, similarly faculty and person are generalization.

Realization
Realization is a relationship between the blueprint class and the object containing its respective implementation level details. This object is said to realize the blueprint class. In other words, you can understand this as the relationship between the interface and the implementing class.
Example: A particular model of a car ‘Maruti Suzuki’ that implements the blueprint of a car realizes the abstraction.

Author: Mahesh

Technical Lead with 10 plus years of experience in developing web applications using Java/J2EE and web technologies. Strong in design and integration problem solving skills. Ability to learn, unlearn and relearn with strong written and verbal communications.