问题
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).
回答1:
Just use a stereotype <<static>>
to model static relationships or attributes
来源:https://stackoverflow.com/questions/21487778/how-to-represent-a-static-relationship-in-an-uml-class-diagram