简体   繁体   English

UML 通信图中涉及的对象之间的关系

[英]Relations between objects involved in an UML communication diagram

In short简而言之

In an UML communication diagram, the objects that interact with each other are visually connected with lines along which sequenced messages can circulate in both directions.在 UML 通信图中,相互交互的对象在视觉上通过线条连接起来,有序的消息可以沿着这些线条在两个方向上循环。 Lines between objects usually represent links, ie instances of an association.对象之间的线通常表示链接,即关联的实例。 But objects can exchange message even if they are not associated (eg if one object is passed as parameter or return to the other).但是即使对象没有关联,它们也可以交换消息(例如,如果一个对象作为参数传递或返回给另一个对象)。

I wish to represent such a message exchange between objects that are not associated.我希望表示不相关的对象之间的这种消息交换。 But I would like to disambiguate and clarify that there is no direct association between the involved objects.但我想消除歧义并澄清所涉及的对象之间没有直接关联。 Do the UML specs allow to express this without creating user-defined stereotypes? UML 规范是否允许在不创建用户定义的构造型的情况下表达这一点?

Moreover do the current UML specifications define somewhere a term for the relation between objects in a communication diagram that interact ?此外,当前的 UML 规范是否在某处定义了交互通信图中对象之间关系的术语? And is it possible to further specify in the diagram how the communicating objects know about each other?是否可以在图中进一步指定通信对象如何相互了解?

More research done before asking the question在提出问题之前进行了更多研究

I am currently re-reading " The UML User Guide, 2nd edition " by Grady Booch, James Rumbaugh and Ivar Jacobson, a great book that explains the UML specifications in reader-friendly plaintext.我目前正在重新阅读 Grady Booch、James Rumbaugh 和 Ivar Jacobson 合着的“ The UML User Guide, 2nd edition ”,这是一本以易于阅读的明文解释 UML 规范的好书。 It's the updated UML 2 edition of the book and I could map back to the UML 2.5.1 specifications most of their claims.这是本书的更新 UML 2 版本,我可以将他们的大部分声明映射回 UML 2.5.1 规范。

In chapter 16 on interactions however, they explain that objects communicate along links:然而,在关于交互的第 16 章中,他们解释了对象通过链接进行通信:

A link specifies a path along which one object can dispatch a message to another (or the same) object.链接指定了一个路径,一个对象可以沿着该路径将消息发送到另一个(或相同的)对象。 (...) If you need to be more precise about how that path exists, you can adorn the appropriate end of the link with one of the following constraints: (...) 如果您需要更精确地了解该路径的存在方式,您可以使用以下约束之一装饰链接的适当末端:

  • association: (...) object is visible by association关联:(...)对象通过关联可见
  • self: (...) object is visible because it is the dispatcher of the operation self: (...) 对象是可见的,因为它是操作的调度程序
  • global: (...) object is visible because it is in an enclosing scope global: (...) 对象是可见的,因为它在封闭范围内
  • local: (...) object is visible because it is in a local scope local: (...) 对象是可见的,因为它在本地范围内
  • parameter: (...) object is visible because it is a parameter参数:(...) 对象是可见的,因为它是一个参数

In chapter 19, they explain for communication diagrams that objects involved in the interaction are shown interlinked:在第 19 章中,他们为通信图解释了交互中涉及的对象显示为相互关联的:

you render the links that connect these objects as the arcs of this graph.您将连接这些对象的链接呈现为该图形的弧。 The links may have rolenames to identify them.链接可能有角色名来识别它们。 Finally, you adorn these links with the messages that objects send and receive.最后,用对象发送和接收的消息装饰这些链接。

This seemed straightforward.这看起来很简单。 So I looked for the corresponding UML 2.5.1 specifications:于是我找了对应的UML 2.5.1规范:

  • Links are solely defined as instances of associations.链接仅被定义为关联的实例。
  • For communication diagrams, there is no mention at all in section 17.9 of links nor communication channels.对于通信图,第 17.9 节中根本没有提及链接和通信渠道。 Figure 17.26 shows interlinked objects (ie lifelines), but the lines linking the objects AND the arrows representing the messages along this line seem both to be graphically defined as "messages".图 17.26 显示了相互关联的对象(即生命线),但是连接对象的线和沿着这条线表示消息的箭头似乎都被图形化地定义为“消息”。 This seems very ambiguous to me.这对我来说似乎非常模棱两可。
  • Moreover I have not found any reference to constraints, keywords or pre-defined stereotypes that could describe how the objects know about each other in a particular diagram and that could justify a communication channel between them.此外,我还没有找到任何对约束、关键字或预定义构造型的引用,它们可以描述特定图中的对象如何相互了解,并且可以证明它们之间的通信通道是合理的。
  • I could find «association» , «local» , «global» , «parameter» (with the same meaning as above) defined as stereotypes in the obsolete UML 1.4 specification, but no longer in the current specs.我可以找到«association»«local»«global»«parameter» (含义与上述相同)在过时的 UML 1.4 规范中定义为构造型,但在当前规范中不再存在。

Hence my question.因此我的问题。

The specification doesn't say this explicitely, but I think this is the definition of link used:规范没有明确说明这一点,但我认为这是所用链接的定义:

Two objects are said to be linked, when they can interact with each other.当两个对象可以相互交互时,就说它们是链接的。

There are several places in the specification that talk about links.规范中有几个地方谈到了链接。 The most general one I found in 11.2.3.3我在11.2.3.3中找到的最通用的

Each link may be realized by something as simple as a pointer or by something as complex as a network connection, and may represent the possibility of instances being able to communicate because their identities are known by virtue of being passed in as parameters, held in variables or slots, or even because the communicating instances are the same instance.每个链接都可以通过像指针这样简单的东西或像网络连接这样复杂的东西来实现,并且可能代表实例能够进行通信的可能性,因为它们的身份通过作为参数传入,保存在变量中或插槽,甚至因为通信实例是同一个实例。

From this I derived my simple definition.由此我得出了我的简单定义。

So, I disagree, links are not "solely defined as instances of associations" .所以,我不同意,链接不是“仅被定义为关联的实例” This misunderstanding probably stems from the fact, that specifying links with InstanceSpecifications is only possible for Associations: Each InstanceSpecification that wants to have slots for the linked InstanceSpecifications must have an Association as Classifier.这种误解可能源于这样一个事实,即使用 InstanceSpecifications 指定链接仅适用于 Associations:每个想要为链接的 InstanceSpecifications 提供插槽的 InstanceSpecification 必须有一个 Association 作为分类器。 But - links can be there even if they are not specified.但是 - 即使没有指定链接也可以存在。 And they can be specified by other model elements.它们可以由其他模型元素指定。

These other link specifying model elements include connectors in composite structure diagrams or messages in interaction diagrams or attributes and parameters in class diagrams.这些其他指定模型元素的链接包括复合结构图中的连接器或交互图中的消息或类图中的属性参数

Communication diagrams are just a way to show an interaction.通信图只是显示交互的一种方式。 They have the same underlying metamodel instances as a sequence diagram.它们具有与序列图相同的底层元模型实例。 Therefore, even though there are lines in between the lifelines, there is no corresponding model element.因此,即使生命线之间有线,也没有对应的模型元素。 They are just there to have a place for attaching the message symbols (see Table 17.4 Graphic Paths Included in Communications Diagrams).它们只是用于附加消息符号的位置(参见表 17.4 通信图中包含的图形路径)。

It is possible for a message to reference a connector.消息可以引用连接器。 So, you can view the line in the communication diagram as a visual representation of this connector.因此,您可以将通信图中的线视为此连接器的可视化表示。 However, it is not necessary to model the connector explicitely.但是,没有必要明确地对连接器建模。 There are tools that will require a connector, but in the specification the connector is optional.有些工具需要连接器,但在规范中连接器是可选的。

As you say, there are no stereotypes to describe how objects know each other.正如您所说,没有刻板印象来描述对象如何相互认识。 You would need to define your own.您需要定义自己的。 However, there are other possibilities: A Lifeline represents a connectable element, which can either be a parameter or an attribute (or a variable, but nobody uses them).但是,还有其他可能性:生命线表示可连接的元素,它可以是参数或属性(或变量,但没有人使用它们)。 By looking at the represented attribute, you can find out, whether it is a global or local attribute and whether it is an association end.通过查看所代表的属性,可以看出,它是全局属性还是局部属性,是否是关联端。

Having said that, there is a catch.话虽如此,有一个问题。 Officially all represented elements must belong directly or indirectly to the context class of the interaction (same_classifier constraint in 17.12.17.5).正式地,所有表示的元素必须直接或间接属于交互的上下文类(17.12.17.5 中的 same_classifier 约束)。 In most cases I encounter, this context is just the system.在我遇到的大多数情况下,这个上下文只是系统。 This means, all attributes must be global.这意味着,所有属性都必须是全局的。 I had a long conversation with the author of this section, and found out, that the idea was, that an interaction should belong to a collaboration and the connection to the system is via CollaborationUses and roleBindings.我与本节的作者进行了长时间的交谈,发现这个想法是,交互应该属于协作,而与系统的连接是通过 CollaborationUses 和 roleBindings 进行的。 This is the reason, why MagicDraw automatically creates a Collaboration for each Interaction.这就是为什么 MagicDraw 自动为每个交互创建一个协作的原因。

This adds another level of indirection, which solves, as we know ;-) all problems in computer science.这增加了另一个层次的间接性,正如我们所知,它解决了计算机科学中的所有问题。 Fortunately, most tools don't enforce this rule, so we are free to let our lifelines represent attributes and parameters of real components of our systems.幸运的是,大多数工具并不强制执行此规则,因此我们可以自由地让生命线代表系统实际组件的属性和参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 memory_order_seq_cst 操作的“发生在之前”和“在单个总顺序之前”关系之间有什么区别? - What is the difference between "happens before" and "precedes in a single total order" relations for memory_order_seq_cst operations? 涉及通用参考的过载分辨率 - Overload resolution with universal reference involved 对象的类可以在 UML 中改变吗? - Can the class of an object change in UML? 在什么条件下使用 std::memcpy 在对象之间进行复制是安全的? - Under what conditions is it safe to use std::memcpy to copy between objects? UML 共享聚合是否意味着没有循环? - Does UML shared aggregation imply absence of cycles? UML 中的“子集”到底是什么意思? - What does "subsets" mean in UML exactly? 如何在 UML 中 model 协变关联类? - How to model a covariant association-class in UML? UML 类的属性和属性的不同表示法 - Different notations for attributes and properties of UML classes UML 2.5.1中Interaction的“not_contained”约束是什么意思 - What is the meaning of “not_contained” constraint of Interaction in UML 2.5.1 在constexpr中使用argc,是否严格要求所涉及的任何子表达式都是常量表达式? - Using argc in a constexpr, is it strictly required that any sub-expression involved be a constant expression?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM