12

I always thought that the UML aggregate is defined as a black (filled) diamond at the beginning of a path and no arrow head that the end:

|--------|        |--------|
| :MyA   |<>------| :MyB   |
|--------|        |--------|

Today I came across a notation like <>-----> (with an explicit arrow head on the right end). So I looked it up in the UML 2.4 specification and actually found references for both versions.

My favourite reference: "UML and Patterns" by Craig Larman only mentions the first version without the arrow. In the UML specification I found a notice about navigable ends, but I am not sure if this is related and if whats the difference?

Could someone explain this more thoroughly and give an example for the use of each version?

lanoxx
  • 12,249
  • 13
  • 87
  • 142

4 Answers4

13

Any association end can be designated to be "navigable" with the help of a navigability arrow. However, UML's notion of "navigability" does not have a precise meaning and people confused it with the concept of an association end being owned by the class at the other end. This concept of association end ownership by a class means that the association end corresponds to a reference property of that class. This issue has only been clarified in last year's new UML version 2.5, which has introduced a new visual notation for association end ownership, a "dot" as in A composition where the end at the component class is owned by the aggregate class.. This is most likely the intended meaning of what you came across, namely A composition where the end at the component class is "navigable", and what it really means is the following reference property:

enter image description here

For more explanation see this tutorial.

Additional answer to the comment: If your class model specifies the ownership of all association ends, and your class diagram displays them, and there is no ownership dot (nor a navigability arrow), as in A plain composition, then, according to UML 2.5, the association end is "owned" by the association itself. Since we do neither have an ownership dot at the MyA end, both ends are "owned" by the composite association. In terms of the code to write/generate, this would mean that the composite association is not implemented by means of reference properties in either MyA or MyB, but has to be implemented with the help of a separate class, say "MyA-has-MyB", which has two reference properties for referencing both the aggregate and the component of any composition link, as in the following class rectangle:

enter image description here

Gerd Wagner
  • 5,481
  • 1
  • 22
  • 41
  • Could you extend your answer with an example where the dot or arrow head are omitted and explain the difference a little more? – lanoxx Feb 14 '14 at 12:24
  • Just a minor correction: the dot notation was already present in 2.1, but not really used in the UML documentation itself. The newer 2.5 version makes wider use of this notation. As a side note: in Enterprise architect you have to click 4 times before you can set the according property for an association, so it's not only 2nd class but 4th class :-( – qwerty_so Apr 12 '18 at 20:19
1

One arrow means the association is navigable this way. No arrows means the association is navigable BOTH ways. Two arrows are omitted.

It could be a problem, because two ends with undefined navigability look out the same way, but it is the standard.

You can read more thoroughly about associations/navigability/aggregations in this my answer https://stackoverflow.com/a/21478862/715269

Community
  • 1
  • 1
Gangnus
  • 24,044
  • 16
  • 90
  • 149
  • 1
    Your statement that "No arrows means the association is navigable BOTH ways" is not correct. No arrows means that navigability is unspecified. – Gerd Wagner Feb 13 '14 at 22:51
  • @gwag go and look at the VP UML help or the diagrams shown on the UML standard pages. Not long ago I thought as you, too, but those two-sided arrows are simply obsolete. – Gangnus Feb 13 '14 at 23:43
  • 1
    In the latest UML 2.5 spec, they describe three options for visual completeness by tools (on p. 211). The second one is "Suppress all arrows and crosses: no inference can be drawn about navigation" and the third one is "Suppress arrows for Associations with navigability in both directions (in this case, the two-way navigability cannot be distinguished from situations where there is no navigation at all). In any case, if you have an association with arrows in a diagram and there is another one without arrows, then this does not have the meaning you have suggested (navigable in both directions). – Gerd Wagner Feb 14 '14 at 00:29
  • @gnat If you have one association with both arrows and another with no arrows, then you are right. But if the first arrow is with one arrow and the second without them, it has the same two-dir/undefined value I am telling about. I do net see any contradiction with the post. – Gangnus Feb 14 '14 at 08:09
  • 1
    Our discussion just shows that the entire UML notion of "navigability" is confusing and almost void of meaning. What really counts (and what implies "navigability") is the concept of association end ownership. So, the recommendation should be not to care about "navigability", but only about association end ownership. – Gerd Wagner Feb 14 '14 at 09:12
  • @gwag Yes, it is not defined precisely. It is SOME EASY WAY to get from a to b. What is easy, it is for us to decide. But the problem with end owning is that navigation really can be realized as a function or reference-to-reference. So, no owned ends, but some navigability. I think, it is often enough, for I do not believe in code generation. I use dots only when I want to express them. And they are not conveniently realized in tools. :-( – Gangnus Feb 14 '14 at 09:18
0

Direction implies a client/server or master/slave relationship. In the case of aggregation, the usual situation is the programmer uses the aggregate to find the sub-components for that object (e.g., use the car to find the car parts). Directionality towards the part class makes this relationship explicit, though in most cases it is redundant.

Bruce
  • 2,230
  • 18
  • 34
0

An association has two ends. An association’s end is modeled by means of a UML Property which can be owned by the classifier involved at the related end of the association, in that case the association is said to be navigable as the source classifier can directly refer to the target instance (the instance at the other end of the association) by means of that property. Otherwise the property representing the association end may be owned by the association instance itself

see http://lowcoupling.com/post/47802411601/uml-diagrams-and-models-with-papyrus

Andrea Sindico
  • 7,358
  • 6
  • 47
  • 84
  • 1
    Navigability (arrows) and ownership of an association end are not the same. While UML's notion of "navigability" does not have a precise meaning, association end ownership by a class means that the association end corresponds to a reference property of that class. This issue has only been clarified in last year's new UML version 2.5. See chapter 5 of https://oxygen.informatik.tu-cottbus.de/IT/JsFrontendApp/tutorial.html – Gerd Wagner Feb 13 '14 at 23:04