Sequence Diagrams
Sequence diagrams visualize how objects interact over time. They show the order of messages exchanged between participants to accomplish a specific task or scenario.
Core Concepts
Participants
Participants represent the objects or actors involved in the interaction. Each participant has a lifeline - a vertical dashed line extending downward that represents time.
Messages
Messages are the communications between participants, shown as horizontal arrows between lifelines. Time flows from top to bottom.
Activation Boxes
Activation boxes (also called execution specifications) are thin rectangles on a lifeline that show when a participant is actively processing.
Creating Participants
Using the Participant Tool
On a UML Sequence Diagram page, press P or choose Participant from the toolbar's UML menu, then click on the canvas to place participants. New participants line up with the existing ones. Press Return with a participant selected to rename it.
Participant Types
Participants can represent different types of entities:
- Participant - A generic object or system part (rectangle)
- Actor - A user or external system (stick figure)
- Boundary - UI or system boundary
- Control - Process or controller logic
- Entity - Data or domain object
- Database - A data store
Set the Role Type in the Inspector's Arrange tab → UML section.
Creating Messages
Using the Message Tool
Press M to activate the Message tool, then:
- Click on the source participant's lifeline
- Drag to the target participant's lifeline
- Release to create the message
Message Types
| Type | Arrow Style | Description |
|---|---|---|
| Synchronous | Solid line, filled arrow | Sender waits for response |
| Asynchronous | Solid line, open arrow | Sender continues without waiting |
| Return | Dashed line, open arrow | Response to a synchronous call |
| Create | Dashed line, open arrow to box | Creates a new participant |
| Destroy | Line ending with X | Terminates a participant |
| Self Call | Arrow looping back to the same lifeline | A participant calls itself |
Set the Message Type of the selected message in the Inspector's UML section.
Message Labels
Select a message and edit its Label in the Inspector's UML section. Common formats:
methodName()- Simple method callmethodName(param1, param2)- Call with parametersresult := methodName()- Call with return assignment[condition] methodName()- Conditional message (guard)
Activation Boxes
Activation boxes show the period during which a participant is executing or waiting for a response.
Adding Activation Boxes
- Choose Activation from the toolbar's UML menu
- Drag along a participant's lifeline over the span where it is active
- The activation box is placed on that lifeline
Nested Activations
When a participant calls itself (recursive call) or handles multiple nested calls, activation boxes can be stacked.
Fragments
Fragments group messages to show conditional logic, loops, or other control flow.
Fragment Types
| Type | Keyword | Purpose |
|---|---|---|
| Alternative | alt | If-else branching |
| Option | opt | Optional execution (if without else) |
| Loop | loop | Repeated execution |
| Break | break | Exit from enclosing loop |
| Parallel | par | Concurrent execution |
| Critical | critical | Atomic/critical section |
| Negative | neg | Invalid interaction |
| Assertion | assert | Required interaction |
| Ignore | ignore | Messages that may be ignored |
| Consider | consider | Messages that must be considered |
| Reference | ref | Reference to another interaction |
Creating Fragments
- Choose Fragment from the toolbar's UML menu
- Drag a rectangle over the participants and messages you want to group
- Select the fragment and set its Fragment Type in the Inspector's UML section
- Enter a Guard Condition as needed
Fragment Guards
Guards are conditions shown in square brackets:
[x > 0]- Numeric condition[user.isAdmin]- Property check[else]- Default/else branch in alt fragments
Reordering Elements
Moving Participants
Drag participants horizontally to reorder them. Connected messages will follow.
Moving Messages
Select a message and press Cmd+↑ or Cmd+↓ to move it earlier or later in the sequence.
Best Practices
- Start with the main flow - Model the happy path first, then add alternatives
- Keep it readable - Limit to 5-7 participants per diagram
- Use meaningful names - Label messages with actual method names or descriptions
- Show return messages - Especially for synchronous calls where the return value matters
- Use fragments sparingly - Too many nested fragments reduce readability
- Add notes - Use sticky notes to explain complex logic
Example: User Login Flow
A typical login sequence might include:
- User enters credentials
- Client sends login request to Server
- Server validates with Database
- Database returns user record
- Server creates session
- Server returns success/failure to Client
- Client updates UI
This flow demonstrates synchronous calls, return messages, and potential alt fragments for success/failure paths.