How to Model Gates in UML Sequence Diagrams

To pass a message between two sequence diagrams in UML modeling, we can make use of gates. Through modeling gates, we could relate the message outside an interaction fragment with message inside another interaction fragment.

Graphically a gate, with an arrowed line, connects to the sequence diagram’s frame edge with one end and the other end connected to a lifeline.

In this tutorial we will show you how to model gates in sequence diagrams using Visual Paradigm for UML (VP-UML).

Steps to model gates

  1. Let’s say we have a simple sequence diagram as shown below.

    01 - a simple sequence diagram to begin with

    01 – a simple sequence diagram to begin with

  2. Suppose there’s a back-end component represented by an interaction use.
    From the Diagram Toolbar, drag Interaction Use onto the sequence diagram.

    02 - add an ( interaction use ) to the diagram

    02 – add an ( interaction use ) to the diagram

  3. Right click on the interaction use and select Refers to > New Sequence Diagram.

    03 - select to elaborate the interaction use

    03 – select to elaborate the interaction use

  4. Rename Sequence Diagram 2 to withdraw money inside the tab in the corner.

    04 - rename Sequence Diagram 2 to ( withdraw money )

    04 – rename Sequence Diagram 2 to ( withdraw money )

  5. Back in Sequence Diagram 1, drag the Message -> LifeLine icon (from ATM Controller) to withdraw money. Release your mouse when you reach the frame’s edge.

    05 - add a message to the interaction use

    05 – add a message to the interaction use

  6. When prompted, select <New Gate>.

    06 - a gate appears

    06 – a gate appears

  7. Double click on the text “withdraw money” (inside the interaction use) to go to that sequence diagram. In it, you should see the Gate automatically inserted for what you’ve just drawn in Sequence Diagram 1.

    07 - the same gate appears on the withdraw money sequence diagram

    07 – the same gate appears on the withdraw money sequence diagram

  8. Drag the Message -> LifeLine icon (from Gate) to the right and release mouse to create a new lifeline.

    08 - create a new lifeline in the withdraw money sequence diagram

    08 – create a new lifeline in the withdraw money sequence diagram

  9. Back in Sequence Diagram 1, add another gate. Drag Gate from the Diagram Toolbar to withdraw money (Note: You would see a letter ‘M’ displayed to indicate that it is a master view).

    09 - add another gate to the interaction use

    09 – add another gate to the interaction use

  10. If you look at the withdraw money sequence diagram, you should see Gate2 which has been automatically inserted with our new addition from the previous step.

    10 - Gate2 automatically appears in the other sequence diagram

    10 – Gate2 automatically appears in the other sequence diagram

  11. We’ll now send a message from LifeLine back to Gate2.
    Place Gate2 below Gate.
    Select LifeLine and drag the Message -> LifeLine icon to the left. Release your mouse when you reach the right edge of Gate2.

    11 - connect lifeline to Gate2 (the other sequence diagram)

    11 – connect lifeline to Gate2 (the other sequence diagram)

  12. Back in Sequence Diagram 1, drag the Message -> LifeLine icon backwards (from Gate2) to ATM Controller.

    12 - connect Gate2 to ATM Controller

    12 – connect Gate2 to ATM Controller

  13. You should end up with a diagram that looks something like this.

    13 - The sequence diagram you would end up with

    13 – The sequence diagram you would end up with

What happens if you change the label of a gate in one of the diagrams?

Gates in Sequence Diagram 1 and the withdraw money sequence diagram share the same models in repository. So changes to them will be synced across these diagrams.

For example, if you rename the top gate to “input” in Sequence Diagram 1, you’ll see that the gate in the withdraw money sequence diagram will also be renamed to “input” automatically.

14 - change reflected across

14 – change reflected across

Related Links

Related Articles

1497 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply