inheritance - 是否有在 UML 静态类图中显示重写方法的约定?

标签 inheritance uml overriding

如果类 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/

相关文章:

Java 重写方法问题

c++11 - C++11 中的最终非多态类

C++类继承变量

c++ - 可以将指向子对象的指针视为指向父对象的指针吗?

.NET:继承修改基类(C++转换)

java - 用于生成 Java 源代码的 Eclipse UML 插件

javascript - 如何扩展 Javascript 原型(prototype)?

node.js - 如何在 Node.js 的模块内使用 Object.create 进行继承

uml - 如何在 UML 中为字典添加简单的泛型类型注释?

c# - 来自 Model 的完整 Java/C# 代码生成工具?