Chr*_*iss 5 uml classification associations relationship
7.3.3 关联(来自内核),第 36 页,UML 上层结构,v2.4.1:
UML 中是否有关于分类器拥有的关联和关系拥有的关联的真实示例?
克里斯
我希望这个简单的例子有帮助。
猜猜你有一个 Java 类
public class A {
private B b;
...
}
Run Code Online (Sandbox Code Playgroud)
在 UML 中,您可以将此关系建模为从 A 到 B 的关联:
甲->乙
具有以下建模元素:
Class B
Class A
+ Property b : B [0..1] (owned by the class)
Association A_to_B
+ Property from_a : A [1] (owned by the association)
Run Code Online (Sandbox Code Playgroud)
其中关联 A_to_B 将有 2 个关联(成员)结束,引用上面显示的两个属性(A::b 和 A_to_B::from_a):
现在,让我们考虑以下情况
public class A {
private B b;
...
}
public class B {
private A a;
...
}
Run Code Online (Sandbox Code Playgroud)
在 UML 中,您可以对 A 和 B 之间的关联(可通过两种方式导航)进行建模:
A <-> B
其模型元素是:
Class B
+ Property a : A [0..1] (owned by the class)
Class A
+ Property b : B [0..1] (owned by the class)
Association A_B
Run Code Online (Sandbox Code Playgroud)
其中关联 A_B 将有 2 个关联(成员)结束,引用上面显示的两个属性(A::b 和 B::a)。