Sequence Diagrams - PowerPoint PPT Presentation

About This Presentation
Title:

Sequence Diagrams

Description:

Sequence Diagrams (Based on Stevens and Pooley (2006, Chapters 9, 10) and Fowler (2004, Chapter 4)) David Meredith Aalborg University * * Interaction diagrams Use ... – PowerPoint PPT presentation

Number of Views:311
Avg rating:3.0/5.0
Slides: 13
Provided by: DavidM533
Category:

less

Transcript and Presenter's Notes

Title: Sequence Diagrams


1
David MeredithAalborg University
  • Sequence Diagrams
  • (Based on Stevens and Pooley (2006, Chapters 9,
    10) and Fowler (2004, Chapter 4))

2
Interaction diagrams
  • Use case diagram describes tasks that system must
    help actors to perform
  • Class diagram describes classes required to
    realize use cases and relationships between these
    classes
  • Interaction diagrams describe how objects
    interact to realize the use case scenarios

3
Sequence diagrams
  • Sequence diagram shows how actors and objects
    interact to realize a use case scenario
  • Only shows actors and objects involved in the
    scenario
  • Each object or actor is called a participant and
    is represented by an icon in a row across the top
    of the diagram
  • Extending down the page from each participant is
    a dashed line called a lifeline
  • Time is understood to move forward as we move
    down the diagram
  • A message sent from participant A to participant
    B is represented by an arrow with a solid line
    drawn from the lifeline of A to the lifeline of B
    (sync msg 2)
  • If A has to stop computing while B carries out
    the operation invoked by the message sent to it
    by A, then this message is said to be synchronous
    and control is passed from A to B
  • A synchronous message is represented on a
    sequence diagram by an arrow with a solid black
    triangular head

4
Sequence diagrams
  • When B receives the message, it starts to have a
    new live activation, denoted here by V
  • This activation is represented by drawing a
    narrow rectangle covering the lifeline of B,
    starting at the point where the arrow
    representing the message from A hits the lifeline
    of B
  • In a procedural interaction (no concurrency),
    exactly one object is computing at any given
    instant
  • If B sends a message to another object, C, B may
    stop computing temporarily while C starts to have
    a new live activation, X
  • B will continue to have the live activation, V,
    until it has finished carrying out the operation
    invoked by the message, sync msg 2, sent to it by
    A
  • At the end of its activation, B might send a
    return value to A, indicated by the dashed arrow
    with the stick head shown

5
Sequence diagrams
  • Can indicate when an object is computing by
    shading those periods on the activations
  • For readability, the participants should
    generally be arranged in the order in which they
    first participate in the interaction
  • This means that most of the message sends are
    represented by arrows that go from left to right
  • If an object of class A sends a message to an
    object of class B in a sequence diagram, this
    implies that there is an association between
    class A and class B in the class model
  • In procedural systems, only actors can initiate
    activity by sending a message "out of the blue"
  • System objects can only send messages when they
    have been made active by receiving a message from
    another object

6
Sequence diagrams
  • At any given instant there will be a stack of
    live activations and the one at the top of the
    stack will be the one that currently has control
    and is computing
  • All the other activated objects are waiting to
    receive control back from objects to which they
    have sent messages
  • If the object whose activation is currently at
    the top of the stack (e.g., B) sends a message,
    then the object that receives this message (C)
    becomes active and its activation (X) becomes the
    top of the stack
  • If the activation X of the object, C, is at the
    top of the stack and it terminates, then its
    activation is removed from the stack and control
    returns to the object B whose message send, sync
    msg 3, started the activation X
  • The activation V during which sync msg 3 was sent
    then becomes the new top of the stack

7
Sequence diagrams
  • If an object sends a message to itself, then the
    object gets another new live activation
  • That is, the object now has two live activations
    on the stack
  • Represented on sequence diagram by a nested
    activation, with activation resulting from
    message to self slightly offset from older
    activation

8
More advanced features
  • Diagram describes process of promoting me to be
    Head of Department within personnel department
    database
  • No need to name participant objects and actors
  • Can just precede class of object with a colon to
    indicate that participant is an object, not a
    class
  • Reply message arrow can be labelled with
    assignment of return value to a variable
  • Actual value returned can be given after colon
  • Object disposal or destruction indicated by a
    synchronous message sent to the object whose
    lifeline is terminated with an X
  • Construction of new object indicated by
    horizontal asynchronous message arrow directly to
    the head of the new participant
  • Asynchronous message arrow has stick head
  • Synchronous message arrow has solid black
    triangular head
  • Asynchronous message starts a new thread of
    control
  • Participant that sends asynchronous message
    continues computing after sending message

9
Conditional behaviour
  • Different scenarios within a use case can
    sometimes be represented on same sequence diagram
    by guarding parts of the interaction with
    conditions
  • Conditional behaviour enclosed within rectangle
    labelled opt (for optional)
  • Guard condition written between square brackets
    near opt label

10
Conditional behaviour and loopsloop and alt
frames
11
Concurrency and asynchronous calls
  • In single-threaded, procedural interaction, only
    one participant computing at any given time and
    all messages are synchronous
  • When object sends synchronous message, stops
    computing and loses control until receiver
    finishes handling message and returns
  • Return may be indicated on diagram
  • In multi-threaded, concurrent interaction, two or
    more objects computing simultaneously
  • Some messages may be asynchronous
  • When object sends asynchronous message, can
    continue computing and recipient also gets a live
    activation generates two concurrent threads

12
Summary
  • Interaction diagrams describe how objects
    interact to realize use cases
  • Sequence diagrams
  • participants, lifelines, activations, messages,
    returns
  • synchronous and asynchronous messages
  • messages to self
  • representing creation and destruction of objects
  • representing return values
  • representing conditionals and loops
  • asynchronous calls and concurrency
Write a Comment
User Comments (0)
About PowerShow.com