UML Sequence Diagrams - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

UML Sequence Diagrams

Description:

Use case: Make Phone Call. User presses the digit buttons to enter the phone number. ... To make outgoing call (after dialling digits) To answer incoming call ... – PowerPoint PPT presentation

Number of Views:163
Avg rating:3.0/5.0
Slides: 19
Provided by: vinodmu
Category:
Tags: uml | diagrams | sequence

less

Transcript and Presenter's Notes

Title: UML Sequence Diagrams


1
UML Sequence Diagrams
  • MIE456 - Information Systems Infrastructure II
  • Vinod Muthusamy
  • November 19, 2004

2
UML diagrams
  • Static models
  • Class diagram
  • Describe types of objects and their relationships
  • Static model
  • But software is about behaviour which is dynamic
  • Dynamic models
  • Show interactions between components
  • Dont show software structure or dependencies as
    clearly

3
Dynamic models
  • 3 types of dynamic models
  • State diagram
  • Collaboration diagram (type of interaction
    diagram)
  • Sequence diagram (type of interaction diagram)
  • State diagram
  • Describe how state changes in response to events
  • State is the properties of an object
  • Interaction diagrams
  • Show flow of messages between objects
  • Useful for describing procedural flow, finding
    race conditions
  • Collaboration and sequence diagrams show same
    information
  • Collaboration diagrams emphasize roles and their
    interactions
  • Sequence diagrams emphasize time (useful for
    real-time applications)

4
Running example
  • Cellular phone
  • Will show
  • Static UML model
  • Class diagram
  • Dynamic UML models
  • Collaboration diagram
  • Sequence diagram

5
Class diagram
  • Dialer gather digits, emit tones
  • Cellular Radio communicate with cellular network
  • Button, Speaker, Microphone, Display hardware

6
The dynamic interactions
  • Dynamic models are based on a use case
  • Use case Make Phone Call
  • User presses the digit buttons to enter the phone
    number.
  • For each digit, the display is updated to add the
    digit to the phone number.
  • For each digit, the dialer generates the
    corresponding tone and emits it from the speaker.
  • User presses Send
  • The in use indicator is illuminated on the
    display
  • The cellular radio establishes a connection to
    the network.
  • The accumulated digits are sent to the network.
  • The connection is made to the called party.

7
Collaboration diagram
  • Objects with names
  • Note 2 Button objects
  • Arrows are messages
  • Sequence numbers tell order
  • Links must correspond to class diagram

8
Sequence diagram
9
Sequence diagram syntax
  • Vertical axis time (increases down)
  • Horizontal axis components (no order)
  • Objects or classes
  • Rectangles across the top
  • Class name MyClass
  • Object name MyObjectMyClass
  • Anonymous object MyClass
  • Lifeline of an object
  • Dashed vertical line from object
  • The time an objects exists
  • Messages
  • Arrows between objects
  • Messages ordered vertically (no need for sequence
    numbers)
  • Procedure call, RMI, JDBC,
  • Activations
  • Hollow vertical rectangles
  • Show duration of execution
  • Directly or by subordinate
  • Shows call stack
  • Return message
  • Implicit at end of activation
  • Explicit with a dashed arrow
  • Iterations
  • Rectangle to enclose messages in iteration
  • Looping condition at bottom

10
Object lifetimes and asynchronous messages
  • Object creation
  • Message arrow pointing to object rectangle
  • Object destruction
  • A large X
  • Can be in response to a message
  • Object can destroy itself at the end of an
    activation
  • Asynchronous messages
  • Half arrow
  • No return value expected
  • Activation of caller may end before return
    message
  • Activation of callee continues
  • End of callee activation does not imply return
    message
  • Nicely shows concurrent interactions
  • Hard to show in Collaboration diagram

11
Race conditions
12
Race conditions (2)
  • E.g. an object receives two messages
  • Order of arrival changes behaviour
  • Only one order leads to correct behaviour
  • CellularRadio expects Answer() not Connect(pno)
  • Two states when Send can be pressed
  • To make outgoing call (after dialling digits)
  • To answer incoming call
  • State diagram can be useful here
  • To help realize there is a race condition
  • To specify what should happen
  • Angled arrows
  • Show message delay
  • Can show race conditions clearer

13
Timing constraints
  • Useful in real-time applications
  • May be useful to specify race condition behaviour
  • Two ways to specify
  • Note message labels

14
Linking sequence diagrams
  • Use dangling arrows
  • Notes clarify other end of dangling arrow
  • Try to group common sub-sequences together

15
More syntax
  • Actor
  • Conditional
  • Specify gt 1 case
  • Branch messages
  • Label arrows
  • Note does not imply concurrent processing
  • Concurrent lifelines
  • For conditionals
  • For concurrency
  • Recursion

16
Some notes for Milestone 2
  • Use proper syntax for object/class names, message
    arrows, etc.
  • Show full lifelines (including possible creation
    and destruction) and activations
  • Show all message names, and parameters
  • Show explicit return
  • Try to keep message flow left to right (not
    always possible in complex applications)
  • Add notes for clarity if necessary
  • Learn to use an appropriate tool to draw the
    diagrams

17
Conclusions
  • Sequence diagrams show interactions of a use case
  • A visual coding technique
  • Make time explicit
  • Very useful for real-time applications
  • Often iterate between static and dynamic models
    during design phase
  • E.g. sequence diagrams can help identify new
    responsibilities for a class or need for a new
    class (changes class diagrams)

18
References
  • Figures are from
  • Object Mentor UML articles
  • UML Class Diagrams by Robert C. Martin
  • UML Collaboration Diagrams by Robert C. Martin
  • UML Sequence Diagrams by Robert C. Martin
  • http//www.objectmentor.com/resources/listArticles
    ?keytopictopicUML
  • OMG Unified Modeling Language, v1.5 Specification
  • http//www.omg.org/technology/documents/formal/uml
    .htm
Write a Comment
User Comments (0)
About PowerShow.com