4

I'm having trouble finding a good answer for how to represent a relationship between two classes A and B, where an instance of A is a static (class scope) variable in B. For example:

class A {

}

class B {
    static A a;
}

I'm not even sure if it is a regular association or a dependency (or something else?).

One idea would be to use a stereotype on the role name of A in the relationship, but I have never seen that done. And since I understand that it is 'rule' not to use both an attribute and a relationship to represent the same member I can't either underline an attribute called 'a' (since I rather want to model the contents of the class A).

user3258493
  • 41
  • 1
  • 3
  • UML was supposed to be more easy to grasp...You may be able to represent this by an arrow with head pointing to B and with the head ending in a filled circle, then add <>. See: http://www.uml-diagrams.org/property.html at section: "Attribute Vs. Member End of Composition or Association". – NoChance Feb 01 '14 at 10:08
  • possible duplicate of [How to show usage of static methods UML Classdiagram](http://stackoverflow.com/questions/11209240/how-to-show-usage-of-static-methods-uml-classdiagram) – Stuart Rossiter Mar 12 '15 at 10:42
  • @StuartRossiter the case is different. The question you reference asks for methods which by default are inline. Here the question is about a relationship shown in a graphical form of an arrow. – Ister Nov 20 '19 at 10:00

1 Answers1

0

Just use a stereotype <<static>> to model static relationships or attributes

gefei
  • 18,922
  • 9
  • 50
  • 67