如果类 Human
继承了父类(super class) Mammal
的一些方法(例如 laysEggs: () -> false
),并覆盖其他方法(例如 postsToStackOverflow : () -> true
),Human
的 UML 静态类图部分中指示不同方法的方式有什么区别吗?例如,Human
框中仅显示重写的方法,还是两者都显示,并带有重写方法的一些注释?
最佳答案
现在有了。一些匿名者让我深入研究2.5.1. specs 。上页。 102 它说
Members that are inherited by a Classifier may be shown on a diagram of that Classifier by prepending a caret ’^’ symbol to the textual representation that would be shown if the member were not inherited. Thus the notation for an inherited Property is defined like this:
<inherited-property> ::= ’^’ <property>
where
<property>
is specified in 9.5.4.Similarly, the notation for an inherited Connector is defined like this:
<inherited-connector> ::= ’^’ <connector>
where
<connector>
is specified in 11.2.4.Analogous notations may be used for all NamedElements that are inheritedMembers of a Classifier to indicate that they are inherited.
Inherited members may also be shown in a lighter color to help distinguish them from non-inherited members. A conforming implementation does not need to provide this option.
由于它适用于 NamedElements,因此它也可用于属性和操作。
除了第 9.11 页的图 9.11 之外,规范本身(还)没有大量使用插入符号。 115 和第 10.9 页173.
<小时/>在 2.5 之前的规范中,答案是:不,没有。您只能通过检查继承自的类的方法来判断方法是否被重写。
关于inheritance - 是否有在 UML 静态类图中显示重写方法的约定?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28930476/