UML 2.5.1 中交互的 "not_contained" 约束是什么意思

What is the meaning of "not_contained" constraint of Interaction in UML 2.5.1

UML 规范 2.5.1,第 17.12.11.5 节提供了有关交互分类器约束的信息。约束not_contained解释如下:

An Interaction instance must not be contained within another Interaction instance.

inv: enclosingInteraction->isEmpty()

现在,当我查看显示交互的抽象语法的图 17.1 时,我看到交互分类器是片段分类器的泛化。因此,一个Interaction是一个Fragment,反之则不然。

另外,Interaction分类器有“fragment”关联,“enclosingInteraction”分类器是Fragment分类器的关联。那么,如何将上述约束定义为Interaction分类器的约束呢?交互分类器不应有属性“enclosingInteraction”。

我对抽象语法的解释有误吗?以我的理解,上面的OCL定义只适用于片段分类器,而不适用于交互分类器。

inv: enclosingInteraction->isEmpty()

指的是当 InteractionFragmentInteraction 时的抽象语法,然后是 enclosingInteraction为空(其大小为 0)。

没有该约束,Interaction 可以有一个封闭的 Interaction,然后以下内容可能为假:

An Interaction instance must not be contained within another Interaction instance.


关系的目标是让 Interaction 知道它的 InteractionFragment,以及 InteractionFragment 知道它包含 Interaction,并且由于双向关联,不可能有 :

没有意义但在以下情况下允许:

没有必要约束的一种方法是引入额外的 class :

但这不是在 UML 元模型中做出的选择


事实上,在 InteractionFragment 的所有其他特化情况下,enclosingInteraction 不为空(其大小为 1),因为所有它们不能存在于 Interaction :

之外

covered : Lifeline [1..1]{redefines InteractionFragment::covered} (opposite A_covered_events::events) References the Lifeline on which the OccurrenceSpecification appears.

covered : Lifeline [1..1]{redefines InteractionFragment::covered} (opposite A_covered_stateInvariant::stateInvariant) References the Lifeline on which the StateInvariant appears.

An ExecutionSpecification is a specification of the execution of a unit of Behavior or Action within the Lifeline


Interaction classifier should have no attribute "enclosingInteraction"

注意enclosingInteraction定义在InteractionFragment上,Interaction继承它。

tl;dr

避免在你的行为描述中出现循环。

长版

Interaction

An Interaction is a unit of Behavior that focuses on the observable exchange of information between connectable elements.

这描述了您的某段代码。 Interaction 本身就是 InteractionFragment

InteractionFragment is an abstract notion of the most general interaction unit. An InteractionFragment is a piece of an Interaction. Each InteractionFragment is conceptually like an Interaction by itself.

这又(抽象)具体化为OccurrenceSpecification

An OccurrenceSpecification is the basic semantic unit of Interactions. The sequences of occurrences specified by them are the meanings of Interactions.

ExecutionSpecification(也是抽象的)

An ExecutionSpecification is a specification of the execution of a unit of Behavior or Action within the Lifeline. The duration of an ExecutionSpecification is represented by two OccurrenceSpecifications, the start OccurrenceSpecification and the finish OccurrenceSpecification.

StateInvariant

A StateInvariant is a runtime constraint on the participants of the Interaction. It may be used to specify a variety of different kinds of Constraints, such as values of Attributes or Variables, internal or external States, and so on. A StateInvariant is an InteractionFragment and it is placed on a Lifeline.

他们每个人都从不同的方面描述行为。

Interaction 有一个 +enclodingIteraction 继承自 InteractionFragment,它引用任何 Interaction 实例。

现在约束只是说一旦你有这样一个实例,它可能只出现一次,而不是在一些递归描述中。因此,您可以将行为拆分成任何小块,但不能重复其中的一个。


引用自 UML 2.5 元模型中的描述。