UML – Handling Alternative Frames in Sequence Diagrams

sequence-diagramuml

Question

When an alt frame is used in a sequence diagram, and one of the two possibility end the sequence, how is "legal" to continue?

example

I need to represent a sequence in wich there are user and atm

  1. the user insert card
  2. the atm verify card
  3. if card is valid, then it confirm card to user and the sequence continue
  4. if not it to user and the sequence Stop

can someone represent this simple example?

I made this sequence:

image

Is correct?

I assume that the part follow the alt frame imply that "good" case is verified?

Or I need to put all of the sequence of "good case" in the "good case alternative section"?

how can I handle this situation?

Thank's in advance!

Best Answer

I assume that the part follow the alt frame imply that "good" case is verified?

No, that assumption is incorrect. The part following the alt frame will be done when either part of the alt frame completes.

Or I need to put all of the sequence of "good case" in the "good case alternative section"?

Yes, all the steps that belong to the "valid card" alternative of the alt frame need to be shown within that portion of the frame.
If that clutters your diagram too much, you can also draw a seq frame inside the alt frame. The seq frame contains the name of another sequence diagram that describes the steps happening at that point.

Another option is to use a break frame. That would contain the steps for an invalid card (with a guard condition). Either the content of the break frame is executed, or the part of the sequence diagram below the frame.

Related Topic