I understand the difference between aggregation and composition but I am struggling a bit with association. My current understanding is that an association exists between classes when ‘they use each other’, for example, one object is passed to the other during a method call. See also:
http://www.codeproject.com/Articles/330447/Understanding-Association-Aggregation-and-Composit
Both objects exist independently and, in contrast to aggregation, no object is a container class of the other. Does this mean that both objects MUST have a copy of the other(s) (e.g. 1:m relationship) or how else is the association ‘stored’. Any feedback would be very much appreciated.
From the UML Superstructure 2.4.1:
Nothing more, nothing less. and very vague. Because of this, it is also very hard to understand. What I defined (In a course I teach) is a hierarchy of links from dependency to composition where:
AtoBmeans thatAusesBbut indirectly (say by receiving instances of it and forwarding them to other objects).AtoBmeans thatAusesBdirectly, (for example by calling methods)AtoBmeans thatBis part ofA(semantically) butBcan be shared and ifAis deleted,Bis not deleted. Note that this says nothing about how the “is part” is implemented.AtoBis like Aggregation, whereBcannot be shared and ifAis deleted, all of its aggregates (Bs) are deleted also.