我在此UML类图中找不到错误 [英] I cant find the fault in this UML Class diagram
问题描述
此UML图仅存在一个错误,但我不确定是什么错误.
我的猜测是 B
不能成为 A
的一部分,因为它是 C
的超类.
This UML diagram has exactly one fault but I am not sure what it is.
My guess is that B
cant be a part of A
because its the superclass of C
.
有人解决了吗?
推荐答案
如果C是B的特化,它也继承它的关联.这意味着C的任何实例除了是D实例的组成部分外(由于1..1的多样性)都是A实例的组成部分:这与要求专有所有权的UML组成矛盾.
If C is a specialisation of B, it inherits also it’s associations. This implies that any instance of C is a component of an instance of A in addition of being a component of an instance of D (because of the multiplicity of 1..1): this is in contradiction with UML composition which requires an exclusive ownership.
例如,您可以通过删除继承,将roleA旁边的多重性更改为0..1或通过使用聚合而不是A侧面的组合来获得有效的关系图.
You may get a valid diagram for example by removing inheritance, by changing the multiplicity next to roleA to 0..1, or by using aggregation instead of composition on the side of A.
这篇关于我在此UML类图中找不到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!