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 | |
| | |<- - - - - - - - - - - - | ?? |
| | | | |
| | | | |
+------------------------------------------+
| | |
+-+ |
+ +
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With