dcsimg
Association, Aggregation, Composition - Java Implementation Difference
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   varun_chopra
Posted On:   Thursday, January 4, 2007 06:28 PM

To all UML gurus, my question is following:


What is the difference between Java implementation among association, aggregation and composition? If A has relation with B (any of above 3), do we always make object of B a member of class A? Is this the only way to represent above relationships? If yes, then how does it matter in Java projects to use different UML symbols at design time?

Re: Association, Aggregation, Composition - Java Implementation Difference

Posted By:   Christopher_Koenigsberg  
Posted On:   Sunday, January 7, 2007 08:01 PM

...how does it matter in Java projects to use different UML symbols at design time?


Welcome to the real world, where UML diagrams are just for show and tell. (unless you're working at a wonderful place that has paid for, and actually uses, the whole Rational Unified Process, where code actually gets generated and maintained from the diagrams etc.


I think "in theory" (i.e. if this is a 'closed book exam' on what I remember of the UML 1 specs) that first of all, an 'association' is so generic it can cover any kind of situation where one classifier refers to or "uses" another somehow (and may go only one way with just one arrowhead, or both ways with 2 arrowheads). I think (?) 'aggregation' and 'composition' are more specific kinds of 'association' that go one way, not both ways.


I think the difference between 'aggregation' and 'composition' is that in one of them (I forget which) the parent/containing classifier really has nothing of its own beyond the constituent/contained elements (like a Java List, for instance), while in the other, the parent does have some significant state/attributes of its own.


I think (?) it's your judgment call, as the UML diagrammer, reflecting your opinion of the "significance" of the parent's own attributes?

About | Sitemap | Contact