如何在UML序列图中表示与同一类的其他对象的通信?
我有一个关于 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:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将场景划分为多个序列图。
一张图对同一类有多个生命线,例如
i1 : MyClass
和i2 : MyClass
并显示实例之间的交互。如果系统的另一部分调用所有实例的方法bar
,那么您可以绘制这些调用,但该方法内部发生的情况是在不同的序列图中建模的。例如,这是第一个图:
这是第二个图:
You could divide your scenario over multiple sequence diagrams.
One diagram has multiple lifelines for the same class, for example
i1 : MyClass
andi2 : MyClass
and shows the interaction between the instances. If another part of the system calls methodbar
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:
and here is the second diagram: