Sequence Diagram (UML) – Message Flow, Lifelines, Activation Bars, alt, opt & loop
This post is a glossary entry on sequence diagrams – including exam questions and tags.
In a Nutshell
A sequence diagram represents the chronological sequence of messages between objects or system components at runtime.
Compact Technical Description
Sequence diagrams are part of UML and serve to represent interactions between various actors, system components, or objects in a chronological sequence. They show how messages (e.g., method calls) are exchanged between the participants, including their order and responses. The vertical axis symbolizes the passage of time, while the horizontal lanes (lifelines) represent the participants. With control structures such as alt, opt, or loop, conditions, alternatives, or repetitions can be modeled.
Exam-Relevant Key Points
- Part of UML for modeling dynamic processes
- Representation of message flows and their sequence
- Use of lifelines and activation bars
- Models system behavior from a communication perspective (IHK-relevant)
- Helpful in analysis, design, and test case development
- Detection of synchronization problems and error flows
- Supports precise process planning and effort estimation
- Serves as documentation basis for development teams
Core Components
- Actor (e.g., user, admin)
- Lifeline
- Activation bar
- Message (synchronous/asynchronous)
- Response/return message
- Control structure
alt(alternative) - Control structure
opt(optional action) - Control structure
loop(repetition) - Object creation/destruction
- Temporal synchronization
Practical Example
// Example: User logs in
User -> UI : Enter credentials
UI -> Service : Submit credentials
Service -> DB : Query user data
DB --> Service : Result (valid/invalid)
alt Credentials correct
Service -> UI : Redirect to home page
UI -> User : Display home page
else Credentials incorrect
Service -> UI : Return error message
UI -> User : Display error message
end
Explanation: The diagram shows the interaction in a login process with conditional branching for success/failure.
Advantages and Disadvantages
Advantages
- Clear representation of processes
- Visualizes interaction and sequence
- Ideal for technical communication
Disadvantages
- Can become confusing with complex systems
- Only suitable for sequential logic
- No direct representation of parallelism
Typical Exam Questions (with Short Answers)
- What is a sequence diagram? UML diagram for representing chronological processes between system components.
- Lifeline? Vertical line representing an object during its existence in the process.
- What do activation bars serve? Show when an object is actively involved in execution.
- What control structures can be used? alt (alternative), opt (optional), loop (repetition).
- How is an error situation represented?
With an
altblock to distinguish between success and error cases. - Why are sequence diagrams important for testing? They help define and verify expected processes precisely.
- Synchronous vs. asynchronous message? Synchronous messages block the sender until a response is received, asynchronous messages do not.
- How are security requirements represented? Through explicit representation of security-relevant actions such as authentication.
Most Important Sources
- https://plantuml.com/en/sequence-diagram
- https://www.guru99.com/sequence-diagram-uml.html
- https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-sequence-diagram/