Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw multiple returns in UML sequence diagram

In UML sequence diagram a method can have only one return line (at least in Astah I'm unable to draw two return lines from one method), how can I model multiple returns in if-else blocks?

In below example, return line 'a' ends methodX(), how to draw return line 'b'?

String methodX(int i) {
  if (i>0)
    return 'a';
  else
    return 'b';
}

     +------------+            +------------+
     |    Foo     |            |     Bar    |
     +-----+------+            +------+-----+
           |                          |
           |        methodX(i)         |
          +-+----------------------->+-+
          | |                        | |
  +-----+------------------------------------+
  | alt | | |  [i>0]                 | |     |
  +-----+ | |           a            | |     |
  |       | |<- - - - - - - - - - - -+-+     |
  |       | |                         |      |
  |       | |                         |      |
  +------------------------------------------+
  |       | |  [else]                 |      |
  |       | |                         |      |
  |       | |           b             |      |
  |       | |<- - - - - - - - - - - - | ??   |
  |       | |                         |      |
  |       | |                         |      |
  +------------------------------------------+
          | |                         |
          +-+                         |
           +                          +
like image 478
aleung Avatar asked Jun 12 '12 13:06

aleung


People also ask

How do you show return value in sequence diagram?

To show the return value of a function as a reply message in an animated sequence diagram, you can use one of a number of predefined macros within the code of your function. This means that the return value for your function visually displays as a reply message on your sequence diagram.

Can we have multiple sequence diagram?

Once you have different use cases, you need separate sequence diagrams. For a parametrized use case, you can create parametrized sequence diagram. Extension points are representing in sequence diagrams by call to other behaviour, which means separate diagram.

Can sequence diagram have multiple actors?

Note that a sequence diagram can have multiple actors. Lifeline – this is a vertical parallel dashed line showing the object's existence in time. Multiple lifelines can never overlap.


1 Answers

The problem is with your tool, not with UML. Check out visual paradigm for UML. You can manually add activations at the start of each alt fragment and at the end of the activation send the return message.

like image 64
vainolo Avatar answered Sep 30 '22 09:09

vainolo