Originally posted by ankur rathi:
A bit off topic. Sorry. How do you differentiate b/w association vs aggregation and association vs composition?
Thanks!
Hi, the association is a line with an optional arrows at every end (if the navigation is bidirectional you will not see any arrow), the aggregation is a line (just like association) but with an diamond at the beginning, and composition is the same as aggregation but with a fill diamond.
now, the differences are:
Association: two classes are related by a variable in the class members
Aggregation: one of the classes has a collection of another class but if the collection is empty the class is still valid
Composition: on of the classes has a collection of another class but if the collection is empty the parent class is meaningless.
Examples:
Association: a Person have a Dog
Aggregation: a Person have pets (more than 1)... if the person does not have pets is still a valid person
Composition: a Company have employees (more than 1), if the company does not have employees is not a valid company... or a Book as Pages, if the Book does not have any pages is still a book?
I hope this clarify the concepts... if that were you looking for.