UML Sequence Diagrams - LPU GUIDE...Definition •Sequence diagram is the most common kind of...

Preview:

Citation preview

UML Sequence Diagrams

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.

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.

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.

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

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

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.

Execution Occurrence

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

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

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.

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.

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.

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

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.

Asynchronous Call

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

• Asynchronous messages have an open arrow head.

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.

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.

Reply Message

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

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.

• 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.

Combined Fragment

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

• Combined fragment may have interaction constraints also called guards

Types of Interaction fragments

• alt - alternatives

• opt - option

• loop - iteration

• break - break

• par - parallel

• strict - strict sequencing

• seq - weak sequencing

• critical - critical region

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.

Loop

Break Parallel

Strict Sequencing

Weak Sequencing

Critical Region

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

Communication Diagrams

Also called collaboration diagram

• 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.

• 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.

Examples

Sequence diagram for ATM

Communication Diagram for ATM

Sequence diagram for issuing a book

Collaboration diagram for issuing a book

Thank you

Recommended