41
UML Sequence Diagrams

UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

  • Upload
    others

  • View
    10

  • Download
    0

Embed Size (px)

Citation preview

Page 1: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

UML Sequence Diagrams

Page 2: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Definition

• Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines.

• Sequence diagram describes an interaction by focusing on the sequence of messages that are exchanged, along with their corresponding occurrence specifications on the lifelines.

Page 3: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines
Page 4: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Lifeline

• Lifeline is a named element which represents an individual participant in the interaction.

• A lifeline is shown using a symbol that consists of a rectangle forming its "head" followed by a vertical line (which may be dashed) that represents the lifetime of the participant.

Page 5: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Gate

• A gate is a message end, connection point for relating a message outside of an interaction fragment with a message inside the interaction fragment.

Page 6: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Interaction Fragment

• Interaction fragment is a named element representing the most general interaction unit.

• Examples of interaction fragments are: • occurrence

• execution

• state invariant

• combined fragment

• interaction use

Page 7: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Occurrence

• Occurrence (complete UML name - occurrence specification, i.e. "event description") which represents a moment in time (event)

• at the beginning or end of a message or

• at the beginning or end of an execution.

• FOC

• Examples of occurrences are:• message occurrence• execution occurrence

Page 8: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Message Occurrence

• which represents such events as sending and receiving of signals or invoking or receiving of operation calls. • Destruction Occurrence

• which represents the destruction of the instance described by the lifeline. No other occurrence may appear below the destruction event on a given lifeline.

• The destruction of instance is depicted by a cross in the form of an X at the bottom of a lifeline.

Page 9: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Execution Occurrence

• which represents moments in time at which actions or behavior start or finish.

Page 10: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Execution

• Execution (full name - execution specification, informally called activation) is interaction fragment which represents a period in the participant's lifetime when it is• executing a unit of behavior or action,

• sending a signal to another participant,

• waiting for a reply message from another participant

Page 11: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines
Page 12: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

State Invariant

• represents a runtime constraint on the participants of the interaction.

• It may be used to specify different kinds of constraints, such as • values of attributes or variables,

• internal or external states, etc.

Page 13: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Interaction Use

• which allows to use (or call) another interaction.• Large and complex sequence diagrams could be simplified with interaction

uses.

• It is also common to reuse some interaction between several other interactions.

• The interaction use is shown as a combined fragment with operator ref.

Page 14: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

UML Message

• Message is a named element that defines one specific kind of communication between lifelines of an interaction. • The message specifies not only the kind of communication, but also the

sender and the receiver.

• A message is shown as a line from the sender message end to the receiver message end.

Page 15: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Messages by Action Type

• A message reflects either an operation call and start of execution or a sending and reception of a signal.

• Depending on the type of action that was used to generate the message, message could be one of: • synchronous call

• asynchronous call

• asynchronous signal

• create

• delete

• reply

Page 16: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Synchronous Call

• Synchronous call typically represents operation call - send message and suspend execution while waiting for response.

• Synchronous call messages are shown with filled arrow head.

Page 17: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Asynchronous Call

• Asynchronous call - send message and proceed immediately without waiting for return value.

• Asynchronous messages have an open arrow head.

Page 18: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Create Message

• Create message is sent to a lifeline to create itself.

• It is shown as a dashed line with open arrowhead and pointing to the created lifeline's head.

Page 19: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Delete Message

• Delete message (called stop in previous versions of UML) is sent to terminate another lifeline.

• The lifeline usually ends with a cross in the form of an X at the bottom denoting destruction occurrence.

Page 20: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Reply Message

• Reply message to an operation call is shown as a dashed line with open arrow head (looks similar to creation message).

Page 21: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Messages by Presence of Events

• Lost Message

• is a message where the sending event is known, but there is no receiving event. It is interpreted as if the message never reached its destination. • Lost messages are denoted with as a small black circle at the arrow end of the

message.

Page 22: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

• Found Message

• is a message where the receiving event is known, but there is no (known) sending event. • It is interpreted as if the origin of the message is outside the scope of the

description.

• This may for example be noise or other activity that we do not want to describe in detail.

• Found Messages are denoted with a small black circle at the starting end of the message.

Page 23: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Combined Fragment

• Combined fragment is an interaction fragment which defines a combination of interaction fragments.

• Combined fragment may have interaction constraints also called guards

Page 24: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Types of Interaction fragments

• alt - alternatives

• opt - option

• loop - iteration

• break - break

• par - parallel

• strict - strict sequencing

• seq - weak sequencing

• critical - critical region

Page 25: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

The interaction operator alt means that the combined fragment represents a choice or alternatives of behavior. At most one of the operands will be chosen.

The interaction operator opt means that the combined fragment represents a choice of behavior where either the (sole) operand happens or nothing happens.

Page 26: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Loop

Page 27: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Break Parallel

Page 28: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Strict Sequencing

Weak Sequencing

Page 29: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Critical Region

A critical region is a region with traces that cannot be interleaved by other occurrence

Page 30: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Communication Diagrams

Also called collaboration diagram

Page 31: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

• Communication diagram provides the same information as provided by sequence diagrams but in different way.

• In sequence diagrams we pay attention on time and sequence order but in communication(collaboration) diagram we more emphasis on interaction messages between objects.

Page 32: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines
Page 33: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines
Page 34: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

• Object are represents with rectangles.

• Messages are represented with an arrow and sequence number.

• Conditional statements are denoted by square brackets ‘ [ ]”.

• We can also combine sequence numbers by grouping them using decimal numbers.

Page 35: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines
Page 36: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Examples

Page 37: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Sequence diagram for ATM

Page 38: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Communication Diagram for ATM

Page 39: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Sequence diagram for issuing a book

Page 40: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Collaboration diagram for issuing a book

Page 41: UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of interaction diagram, which focuses on the message interchange between a number of lifelines

Thank you