4

For a UML SEQUENCE DIAGRAM :

Can I create several Alternative flows and Exceptional (Error) flows on a Single Message (any type of message like reflexive, self message or regular message) ?

For instance : Let's say the system (to be automated) is a Public Phone(PP) There are 2 actors : the client (or User) and the PP (the system)

Message A (regular message) From Client to PP : The client enter some change / bill in the device ;

Message B (reflexive message) : The PP verifies that the money entered (coins, bills ...) is authentic (i.e. not fake) AND is greater than the minimal amount to make a call.

So for Message B, there can be at least 2 alternative flows (fake money, not enough money...) and 1 Error (or Exceptional) flow (i.e The client definitely failing to meet the requirements after 3 trials)

Correct me if I'm wrong but I know that the alternative case can say " go to step (or message) x forward or backward " in the nominal (normal) flow of event. So I need alternative / error flows to deal with exceptions.

So To reformulate my question with this example, can I add several alternative / error flown on Message B ( or message A if needed) ? (and this will be a little comment next to the reflexive arrow of Message B)

enter image description here

A1 : Alternative flow 1 A2 : Alternative flow 2 E1 : Error flow

And A1, A2, E1 will be described textually but not with the alt or opt UML formalism

Kurt Miller
  • 567
  • 1
  • 8
  • 23
  • Please provide more context. What you are asking is unclear. – Jim L. Apr 02 '16 at 16:09
  • @JimL. For instance, lets says the system is a Public Phone (PP). The User (only actor here) enters some change / bill into the device (PP). Then the PP verifies 2 things : the authenticity of the money (is it real coins / bills) and the minimum amount required to make a call. My question is for if these things are not verified. Can I add 2 alternatives flows (one for amount not respected and the other for fake change) and one Exceptional case (for the user definitely not succed meeting the requirements after several trials) ? – Kurt Miller Apr 02 '16 at 16:32
  • I can't tell which type of diagram you have in mind yet. – Jim L. Apr 02 '16 at 16:39
  • @JimL. Ohh yes I forgot to say. A SEQUENCE DIAGRAM... – Kurt Miller Apr 02 '16 at 17:09
  • 2
    How about clarifying your original question now? – Jim L. Apr 02 '16 at 17:10
  • @ThomasKilian I did as you asked – Kurt Miller Apr 02 '16 at 19:21
  • @JimL. I edited the original question. Could you take a look at it ? – Kurt Miller Apr 02 '16 at 19:21
  • @ThomasKilian Please see the image I added in my OP – Kurt Miller Apr 02 '16 at 20:14
  • That's exactly the purpose of the alt-fragments. – qwerty_so Apr 02 '16 at 21:07

1 Answers1

4

The answer is: no, you can't. In (very) former UML versions there was a possibility to branch messages (there's a quite recent question about this). But that has been abandoned.

Instead you may use fragments with [alt] to show the different variants.

enter image description here

Community
  • 1
  • 1
qwerty_so
  • 35,448
  • 8
  • 62
  • 86
  • Please see the image I added in my OP – Kurt Miller Apr 02 '16 at 20:14
  • it's enough to comment here. I'll see that. Just imagine that Object1 receives the "Enter money" and then alternatively send O2 or O3 (or does other self-message voodoo). – qwerty_so Apr 02 '16 at 21:09
  • Yeah then with that said... do u mean that my picture is as OK as yours is (in which cas I could add as many A1, A2, .... , An for the self-message) ? – Kurt Miller Apr 02 '16 at 22:14
  • I have update my picture as well. The alt could be narrowed to start below the receiving message. – qwerty_so Apr 02 '16 at 22:37
  • You still haven't told me if the "formalism" of my picture is correct (yes / no ) ? Plus one more question. With the alt fragment, how can I represent "go to step number n" (and that step n is outside the alt fragment prior to it or after it) --> For instance If [cond 2] then restart the sequence at step 2 (let's say there are 5 steps before the alt fragment) – Kurt Miller Apr 03 '16 at 07:33
  • a) you picture is formally correct. b) use the `[cond]` guards to tell which step to take. – qwerty_so Apr 03 '16 at 08:18
  • You are a life-saver bro. a) and b) totally satisfy me. Thank you Very much. Problem solved. – Kurt Miller Apr 03 '16 at 11:06