如何在序列图中呈现静态类或函数调用?
静态类或静态函数的调用如何在序列图中呈现?根据我的理解,生命线属于类的实例/对象。 这篇文章说可以使用元类构造型。
How is a static class or call to a static function presented in Sequence Diagram? As per my understanding, the lifeline belongs to an instance/object of a class. This article says metaclass stereotype can be used.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
“如有疑问,请使用注释或构造型...”
序列图:
类图:
在此示例中,“TurnOn()”是一个返回的静态方法,
“FastFoodTerminal”类的实例(对象)。
"In case of doubt, use comments, or stereotypes..."
Sequence Diagram:
Class Diagram:
In this example, the "TurnOn()" is an static method that returns,
an instance (object) of the "FastFoodTerminal" class.
所以最后是使用构造型来提到静态类/函数。下划线在 UML 2.4.1 Aug 2011 中不再适用,第 86 页,标题符号和演示选项下
So finally it is the use of stereotype to mention a static class/function. Underlining is no more applicable in UML 2.4.1 Aug 2011, page Page 86, under the headings Notation and Presentation Options
我认为你的评论涵盖了大部分内容:
UML 无法完全涵盖这一点,因为静态不是 UML 定义,每种语言都有细微的差异。然而"features"[pg.1]的UML规范69](属性/操作):
请注意,他们说的是分类器本身。所以问题是我可以将分类器放在序列图而不是实例中吗?另请注意,这并没有说分类器可以是静态的。同一 UML 规范的第 27 页显示元类“classifier”(类)中没有 isStatic。因此 UML 没有为静态类提供正式的模型功能。您可以使用构造型或关键字,或者您自己的 UML 配置文件并扩展类。但简短的答案是按照您已经发布的内容进行操作。
I think your comment covers most of it:
UML cannot cover this entirely because static is not a UML definition, each language has slight variances. However the UML spec for "features"[pg. 69] (attr/operations):
Notice that they say the classifier itself. So the question is can I put a classifier a sequence diagram, not an instance? Also notice that is does not say classifier can be static. Page 27 of the same UML spec shows no isStatic in the meta class "classifier" (class). So UML does not provide a formal model feature for static classes. You can use stereotype or keywords, or your own UML profile and extend Class. But the short answer is do what you already posted.