如何在序列图中显示 "if" 条件而没有其他条件

How to show "if" condition without else in sequence diagram

我想知道您如何设计序列图中没有 "else" 的 if 条件?我不知道我是否必须用替代方案来做,因为我只有一个案例或什么都没有,所以我没有任何替代方案。 谢谢你的回答。

我刚刚在第 54 页找到了这篇文档 http://www.omg.org/news/meetings/workshops/MDA-SOA-WS_Manual/00-T4_Matthews.pdf 我找到了选项。我在网上查了一下,好像正是我要的。

像这样使用 opt 片段

条件显示在方括号中。我认为,一个 alt 也只处理一个案例。

不需要包含多个操作数。

规范 (17.6.2) 只要​​求每个片段至少有一个操作数(alt 种类没有其他限制)。

所以你可以做到这一点

正如 Thomas 指出的那样,您可以使用 opt,这等效于(强调我的):

An option is semantically equivalent to an alternative CombinedFragment where there is one operand with non-empty content and the second operand is empty.