views:

64

answers:

4

Is it safe to say that in a UML class diagram, if there is an association of n to 1 objects, then the association arrow is pointing from the class associated with n objects to the class associated with 1 object?

n ----> 1

A: 

Not precisely. It depends on the type of association. If its an aggregation then the default is bi directional navigability, but you can specify the navigation to be one way. I think that it is entirely up to the designer to decide the direction of the navigation between objects.

Vincent Ramdhanie
A: 

I thought the arrow was more about navigability (i.e. an arrow from A -> B shows that class A knows how to get to B but B does not know how to get back to A) than expressing the cardinality of the relationship.

pjp
A: 

No. At least in object oriented programming, the one class that has the "1" association (reference in OOP) could equally well have the many references to the other class.

It depends on the design you make.

Marcel
+2  A: 

Not in general. The arrow direction in UML corresponds to navigation possiblities. Hence, if your arrow points from the n objects to the 1 object it means that in your resulting code each of the n objects can access that 1 object. Of course you may also want an association in which that 1 object can access the n objects, so the arrow points in the different direction. (If no arrowhead is given it means that the n objects can access the 1 object and vice versa.)

Frank

related questions