What is Navigability in UML diagrams? - uml

What is an example of Navigability in UML diagrams? My professor has provided the follow figure, but I can't seem to figure it out:

This shows navigability. A can see (means it has an attribute referencing) B. In contrast B has no idea about/reference to A. As #JimL commented, your arrow is wrong and only used for stereotype definition. I'm referring to the unfilled arrow which indicates navigability of associations from which I assume you actually meant that.
UML 2.5 spec p. 18:
Arrow notation is used to denote association end navigability. By definition, all class-owned association ends are navigable. By convention, all association-owned ends in the metamodel are not navigable.
An association with neither end marked by navigability arrows means that the association is navigable in both directions.
And even more relevant p. 200:
Navigability notation was often used in the past according to an informal convention, whereby non-navigable ends were assumed to be owned by the Association whereas navigable ends were assumed to be owned by the Classifier at the opposite end. This convention is now deprecated. Aggregation type, navigability, and end ownership are separate concepts, each with their own explicit notation. Association ends owned by classes are always navigable, while those owned by associations may be navigable or not.
So you should use the dot notation instead:

The UML specs is an intricate pile of alternative notations that can drive you crazy. Explore with caution!
In real life, KEEP IT SIMPLE! Don't use "dot notation" and don't use x to denote non-navigability, unless your peers are familiar with it.
Use arrows for navigable associations. People are familiar with it, or if not they're intuitive enough.

Related

What means a unidirectional relationship arrow

I don't understand what the relationship between the two tables in the linked picture mean. And how can I code it?
It's with
virtual public Propriete Proprietes { get; set; }
Geert writes true things, but I think, you need more practical advice.
That one-directional arrow means, that the Enquette class has a field or method, that are of the class Propriete. In 99% it is a simply field of that type. Contemporary standard offers to use a point on the other side of the line for this.
The fact, that the arrow has no name on it, often means that the name of the field is propriete, or Propriete, according to the style accepted by the language and your company. (it is not required in UML standard, but it is widely used). According to the last paragraph of the question, it seems, your company uses this rule, too.
The fact, that there is no arrow on the other end of the line, does not mean, that there is no field or method in Propriete class that has a class of Enquette. (Though it meant that in 90-ties). It merely means we haven't decided yet if there are such fields or not. Or maybe, we consider it to be not important. I.e. it is undefined. The known lack of such connection must be shown by a cross instead of an arrowhead.
So, somewhere in Enquette you have a line:
Propriete propriete;
or
Propriete* Propriete; //if you are in C++
or even maybe
Propriete** Propriete;
or cited by you
virtual public Propriete Proprietes { get; set; } // apparently, C#
It could be either static/class field or instance field - it is not defined in the diagram.
And in the class Propriete there can exist the line:
Enquete enquete; // or some of the mentioned variants
And you are leaving the decision about its existence to the coder.
Notice, that a line without arrowheads means that really there are fields (or methods) for both ends. Simply we don't draw arrowheads at all if the line should show two of them.
So, really, you have a mistake in the question. It is NOT an unidirectional relationship. It is an unidirectional arrow showing a relationship, that MAY BE unidirectional.
The arrow at the end of the Association between the Classes (not tables) indicates that this end is navigable.
This is defined as an operation the Property at the end of the Association. The definition in UML 2.5 specs says:
isNavigable() : Boolean
The query isNavigable() indicates whether it is possible to navigate across the property.
body: not classifier->isEmpty() or association.navigableOwnedEnd->includes(self)
Furthermore it says about the Association Notation:
An open arrowhead on the end of an Association indicates the end is
navigable. A small x on the end of an Association indicates the end is
not navigable.
And about the Navigability on an Association
Navigability means that instances participating in links at runtime
(instances of an Association) can be accessed efficiently from
instances at the other ends of the Association. The precise mechanism
by which such efficient access is achieved is implementation specific.
If an end is not navigable, access from the other ends may or may not
be possible, and if it is, it might not be efficient.
And to conclude something to keep in mind because this convention is still often used:
Navigability notation was often used in the past according to an
informal convention, whereby non-navigable ends were assumed to be
owned by the Association whereas navigable ends were assumed to be
owned by the Classifier at the opposite end. This convention is now
deprecated. Aggregation type, navigability, and end ownership are
separate concepts, each with their own explicit notation. Association
ends owned by classes are always navigable, while those owned by
associations may be navigable or not.
So now you should know what it means. How to code it depends on the programming language, the company standards, the architectural layer, your creativity, etc..

UML Aggregation with and without arrow head

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?
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 . This is most likely the intended meaning of what you came across, namely , and what it really means is the following reference property:
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 , 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:
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
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.
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

property owned by an association vs. property owned by a class?

What is the differences between property owned by an association and a property owned by a class in UML?
is there a simple example helps me understand the differences?
The difference is more conceptual than anything else. If you have a property attached to an association, then you will have an association class, with the desired property.
Here is an example of a mailman sending letters to clients (the attribute weight is bound to the association):
The difference is very concrete, but traditionally ignored.
A is associated to B. A,B are classes.
If B end of the association is "association owned" and navigable, it means, that you can easily reach instance of B from A, either by reference, or by some method(s). It should be shown by arrow.
If B end is "classifier owned", you know a bit more. it means, that A has an attribute, that is a direct reference. (No functions or reference counting here). It should be shown by arrow and "dot"- a small black filled circle.
If you are going to B by a.smth.smthelse.b, it is arrow, but surely no dot.
If you are going to B by a.b, it is arrow and dot.
If you haven't decided yet, it is arrow again.
Traditionally modellers show arrows only. But it is not a good tradition, and is against UML standard. Diagrams are more useful if we decide as much as possible on them, not in code.
If both ends are navigable, both arrows disappear and you may see only dot(s).
The association lines with cross with dot on one side, or arrow on one side and only dot on the other are senseless.

Using variables in UML multiplicities

I was running a tutorial today, and a we were designing a Class diagram to model a road system. One of the constraints of the system is that any one segment of road has a maximum capacity; once reached, no new vehicles can enter the segment.
When drawing the class diagram, can I use capacity as one of the multiplicities? This way, instead of having 0..* vehicles on a road segment, I can have 0..capacity vehicles.
I had a look at ISO 1905-1 for inspiration, and I thought that what I want is similar to what they've called a 'multiplicity element'. In the standard, it states:
If the Multiplicity is associated with an element whose notation is a text string (such as an attribute, etc.), the multiplicity string will be placed within square brackets ([]) as part of that text string. Figure 9.33 shows two multiplicity strings as part of attribute specifications within a class symbol. -- section 9.12
However, in the examples it gives, they don't seem to employ this feature in the way I expected - they annotate association links rather than replace the multiplicities.
I would rather get a definitive answer for the students in question, rather than make a guess based on the standard, so I ask here: has anyone else faced this issue? How did you overcome it?
According to the UML specification you can use a ValueSpecification for lower and upper bounds of a multiplicity element. And a ValueSpecification can be an expression. So in theory it must be possible although the correct expression will be more complex. Indeed it mixes design and instance level.
In such a case it is more usual to use a constraint like this:
UML multiplicity constraint http://app.genmymodel.com/engine/xaelis/roads.jpg

UML: Bi-directional and Multiplicity

What is the notation for multiplicity when there isa bidirectional relationship? Are we supposed to list the multiplicity twice for at each arrow?
Multiplicity does not depend on navigation (I assume that by bidirectional you are referring to the navigability of the associations). They are two independent properties. So, yes, multiplicities must be indicated for each end of the relationship
Graphical notation of an association does not have arrows at the end of the association links. Some tools such as eUML or others are adding arrows at the end but this is not a valid UML notation.
If the association is navigable in just one side then you need an arrow at one of the end.

Resources