WEEK 5 CS2002 Sequence Diagrams in UML
Software Development and Management Course
Brunel University LondonDr Giuseppe Destefanisgiuseppe.destefanis@brunel.ac.uk@GiuseppeDes
Introduction to UML Sequence Diagrams
Sequence diagrams model the interactions between objects.
They illustrate how messages and data are exchanged during interactions.
Structure of the Sequence Diagram
Horizontal Axis: Represents interaction partners (actors or systems)
Vertical Axis: Represents the chronological order of interactions
Key Elements
Interaction Partners
Depicted as lifelines:
Head of Lifeline: Rectangle showing role. Example:
roleName:ClassBody of Lifeline: Dashed vertical line representing the lifetime of the interaction partner.
Exchanging Messages
Message Types:
Synchronous: Sender waits for a response before proceeding
Asynchronous: Sender continues immediately without waiting for a response.
Response message: Optional; delivered back to the sender.
Object creation and destruction:
Creation: Dashed arrow points to the new object's lifeline with the keyword
new.Destruction: Large cross marks the end of a lifeline.
Combined Fragments
Used to model various control structures in interactions.
Types of Operators:
alt: For alternative interactions (like
switch)opt: For optional interactions (like
if)loop: For repeated interactions (iterations)
break: For exception handling.
Types of Combined Fragment Operators
alt: Alternative sequences using guards to determine path.
opt: Optional sequence based on a guard, one operand.
loop: Repeated execution of an operand, specifies iterations.
seq: Default order of events, allows weak sequencing.
strict: Ensures strict ordering of messages long various lifelines.
par: Concurrent paths can interleave, but order of operands is irrelevant.
Practical Examples
alt Fragment Example:
Used to model different paths based on a condition, similar to switch statements.
loop Fragment Example:
Details execution with specific minimum and maximum iterations.
strict Fragment Example:
Ensures messages are passed in a precise order between interaction partners.
Notation Elements
Lifeline: Represents interaction partners involved.
Destruction Event: Indicates when an interaction partner ceases to exist.
Combined Fragment: Denotes different control constructs within the interaction.