How to represent an if condition1 else if contion2 on a sequence diagram?

雨燕双飞 提交于 2020-01-03 09:44:14

问题


I was wondering, how can one represent "if cond1 else if cond2" statement on a sequence diagram?

    if (condition1) {
      // Do something
    } else if(condition2)
    {
      // Do something else if
    }

Im not sure if is it with two independent "Opt" clause

If possible create an image representation of a solution.


回答1:


In the sequence diagram, you can use a combined fragment with an alt operator. This allows you to show alternative behaviors:

  • Graphically, the alternatives are in tiled regions separated by dashed horizotal lines.
  • You can document the precise condition for each alternative in a guard (i.e. [condition]).

Example:

Additional reading:

  • UML Basics: the sequence diagram (Article from Rational/IBM)


来源:https://stackoverflow.com/questions/38164421/how-to-represent-an-if-condition1-else-if-contion2-on-a-sequence-diagram

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!