UML "redefines" 是什么意思?

What does UML "redefines" mean?

在 UML 规范中,“重新定义”这个词出现了很多次。没有提到重新定义的含义。也许这太简单了?不管怎样,如果有人能解释得更简单一点就好了。

来自 UML 2.5.1 的快照,区间:


我使用建模工具 (Sparx Enterprise Architect) 找到了有关其功能的线索。如果有另一个接口的子接口class,我可以选择“重新定义”该接口的操作和属性。

我胡乱猜测它的用途,并用更多参数重新定义了它。额外参数表示在将 Matlab 函数编译为 C# 库时由 Matlab 编译器添加的“输出参数数”。然后我继续为 CLI 制作了另一个 sub-class 并相应地重新定义了参数(int return 值,所有输入都是字符串)。

UML 2.5.1 在第 9.2.3.3 节(第 100 页)中定义了重定义:

Any member (that is a kind of RedefinableElement) of a generalization of a specializing Classifier may be redefined instead of being inherited. Redefinition is done in order to augment, constrain, or override the redefined member(s) in the context of instances of the specializing Classifier.

对于属性、属性 或操作等特征:

Feature redefinitions may either be explicitly notated with the use of a {redefines <x>} property string on the Feature or implicitly by having a Feature which cannot be distinguished using isDistinguishableFrom() from another Feature in one of the owning Classifier’s more general Classifiers.

例如,假设您有一个 class Node,它具有两个属性:from: Node[*]to[*]: Node。然后你可以有一个专业化 FamilyMember (你家谱中的一个节点)并且你可以重新定义成员:parent : FamilyMember[*] {redefines from}child : FamilyMember[*] {redefines from}

另一个例子:你有一个多态 class Shape 和一个抽象操作 draw()。您可以将 class 专门化为 class Circle,后者将拥有自己的 draw()。您可以保留隐含的重新定义(仅提及操作),或者您可以使用 draw() {redefines draw()}.

非常明确

抽象语法图将 UML 应用于 UML 元模型。重新定义具有相同的含义,但在第 6 节中以较短的方式进行了解释。

让我们在您的图表中举个例子:让我们以 IntervalConstraint:

  • IntervalConstraint 继承自 Contraint。一个Constraint由一个属性specification:ValueConstraint组成(第36页),所以IntervalConstraint继承了这个属性。
  • 您的图表显示 IntervalConstraint 由 属性 specialization: Interval 组成,它重新定义了更一般的 specification 约束。这是一个重新定义,因为它缩小了它的类型(幸运的是,Interval 继承自 ValueSpecification,所以没有不一致的风险)。