I have a question regarding UML Class diagrams.
I know I can just use one name which refers to both sides but my question is:
Is it necessary to show association names at both sides of an association when it is uni directional?
Association ends are properties (i.e., "variables"). When a class owns a property and the property is unnamed, that could be a problem. In contrast, when an association owns an unnamed property, that's not really a problem. You don't need to specify a name for association-owned properties.
Here's an example. I've made MagicDraw show association-end properties as attributes as well, just to make a point:
Notice how theB
shows up as a property in class A
and at the end of the association with class B
. That's because they are two different ways of showing the same property. (It's a special way of showing association-end properties that we normally don't turn on in the tool.) Also notice how class C
has an unnamed property inside the box and at the end of the association with class A
. Again, that's two different ways to show the same property. How would you implement that unnamed property in a programming language? That could be a problem, right?
Another thing to notice is that class B
does not have an attribute called theA
, and class A
does not have an attribute called theC
. That's because those properties are non-navigable and the associations own those properties.
Conflating navigability and property ownership has become deprecated in UML. Recently, the UML spec introduced "association dot notation" to indicate property ownership. (A dot at the end means the class owns the property.) Personally, I never had a problem with the conflation, and I hate the new dot notation. Many tools do not support it, and I think it's downright ugly. Moreover, a diagram that has no dots on it is ambiguous. You can't tell whether it was drawn before or after dots were introduced to the spec!