如何在UML序列图中表示与同一类的其他对象的通信?

发布于 2025-01-20 13:10:10 字数 424 浏览 4 评论 0原文

我有一个关于 UML 序列图的问题。我有演员系统,其中有许多同一类的对象(演员)相互通信。演员的数量取决于问题,但太大了,无法全部画出来。我还有系统的其他部分(其他参与者),现在我正在绘制 UML 序列图,从时间角度显示参与者之间的通信。我的问题是如何表现同班演员之间的交流?

我发现了这样的东西:

在此处输入图像描述

但看起来像是在对象内调用方法,而不是同一类的其他对象(或者也许我错了?)。我还考虑过在图表上显示两个对象,但随后我必须将箭头数量加倍,因为来自系统其他部分的每次通信都必须与两者连接。您知道第三种解决方案如何正确显示这一点吗?

I have a question regarding UML sequence diagram. I have actor system, where I have many objects (actors) of the same class communicating with each other. The number of actors depends on the problem, but it is too large to draw them all. I have also other parts of a system (other actors) and now I'm drawing UML sequence diagram showing communication between actors with a time perspective. My question is how to show communication between actors of the same class?

I have found something like this:

enter image description here

But it looks like calling method within object and not other object of the same class (or maybe I'm wrong?). I also thought about showing two objects on diagram, but then I would have to double number of arrows, becouse each communication from other part of system would have to be connected with both. Do you know some third solution how to show this properly?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

悲凉≈ 2025-01-27 13:10:10

您可以将场景划分为多个序列图。

一张图对同一类有多个生命线,例如 i1 : MyClassi2 : MyClass 并显示实例之间的交互。如果系统的另一部分调用所有实例的方法 bar,那么您可以绘制这些调用,但该方法内部发生的情况是在不同的序列图中建模的。

例如,这是第一个图:

seq1

这是第二个图:

seq2

You could divide your scenario over multiple sequence diagrams.

One diagram has multiple lifelines for the same class, for example i1 : MyClass and i2 : MyClass and shows the interaction between the instances. If another part of the system calls method bar of all instances, then you could draw those calls, but what happens inside that method is modeled in a different sequence diagram.

For example, here is the first diagram:

seq1

and here is the second diagram:

seq2

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文