I am pretty confused about oops design principles. In UML class diagram there are notations of association and aggregation. I want to undersatnd what is the exact difference between these two, because according to me these are very similar and used for same purpose
Association 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.
Example : A Student and a Faculty are having an association.
Aggregation 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
Example : (City, Tree, Car) "sub objects" (Tree, Car) will NOT be destroyed when City is destroyed.