Sequence diagrams - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

Sequence diagrams

Description:

the sequence of events and interactions between a set of objects ... Can be used at different stages in system development. ... Example - Sequence Diagram 2 ... – PowerPoint PPT presentation

Number of Views:131
Avg rating:3.0/5.0
Slides: 23
Provided by: johnr98
Category:

less

Transcript and Presenter's Notes

Title: Sequence diagrams


1
Sequence diagrams
Object-Oriented Design Module 4
John Leaney, Lian Loke, Lizveth Robles University
of Technology, Sydney
Contributors
John Reekie, University of Technology, Sydney
Terms of Use Creative Commons Attribution-ShareAl
ike 2.5 http//creativecommons.org/licenses/by-sa/
2.5/
2
Overview
  • Last OO design session, we represented the static
    structure of the model for a system in a UML
    Class Diagram
  • Classes, generalization, association
  • This week we will look at UML Interaction
    Diagrams
  • Sequence diagram
  • Quick-and-dirty version
  • Collaboration diagram
  • Referenceshttp//www.softwarepractice.org/coursew
    are/index.php/design/sequence_diagrams

3
Diagrams in UML
Use case Diagram
Development Diagram
Statechart Diagram
Views
Activity Diagram
Component Diagram
Object Diagram
Sequence Diagram
Collaboration Diagram
Class Diagram
Knoernschild, p. 55
UML has a lot of different diagrams! Use them as
appropriate.
4
Interaction Diagrams
  • UML notation for illustrating
  • how objects interact via messages
  • the sequence of events and interactions between a
    set of objects
  • A single diagram is typically drawn for a
    particular scenario or use case.
  • Can be used at different stages in system
    development.
  • We will focus on the use of interaction diagrams
    at the design stage.

5
Common Notation
  • Classes and Instances

Client
Client
c1Client
instance
named instance
  • Message notation

return value message(parameter
parameterType) returnType
s calculateSalary(hours) s calculateSalary
(hours Integer) Double
6
An example sequence interaction diagram
Scenario Check campaign budget
Note The blackened segments show when the object
has the focus of control. You do not normally
show this on your diagrams.
7
Sequence Diagram
  • Shows the sequence of events that occur in a
    scenario
  • Shows the detailed interaction between objects
  • Good for presenting sequence or time ordering of
    messages
  • Constrained format in which more objects are
    added to the diagram horizontally to the right
  • i.e., can run out of room on the paper

8
Sequence Diagram Notation
  • Messages
  • Focus of control and activation boxes
  • Illustrating Returns
  • Messages to self or this
  • Creation of instances
  • Object Lifelines and Object Destruction
  • Iteration or looping
  • Conditional messages

9
Notation Samples 1
synchronous message synchronised with source
by a return messagein context of overall normal
message flow
anonymous objectnot named
Client
getName ( )
Activation boxWhen this message trace is active
return message
object lifeline
10
Notation Samples 2
instance creation message
Campaign
named object
addNewAdvert( )
synchronous message
create( ) ltltcreategtgt
adv1 Advert
autoDestroy()
message to self
object destruction
X
11
Notation Samples 3
12
Notation Samples 4
A
B
C
calculate (x )
xgt10calculate( )
xlt10 calculate( )
Mutual exclusive conditional messages
13
Synchronous and Asynchronous messages
Time constraints are mainly used in real-time
systems
14
Example - Sequence Diagram 2
Scenario Add a new advert to a campaign with
boundary and control classes
15
Quick-and-dirty
  • Sometimes we want to quickly sketch the essence
    of the interaction without bothering about
    correct syntax
  • Here we present a no-frills way of drawing
    sequence diagrams, called Quick-and-dirty
  • Suited to drawing by hand
  • Of course, when formally documenting your design,
    you should use formal UML syntax
  • ? Use Quick-and-dirty sequence diagrams in your
    project workbook to explore and present your
    design

16
Sample 1 Quick-and-dirty
named instance
anonymous instance
player
hand
Card
valueHand
getValue
totalValue
synchronous message
addCard(aCard)
17
Sample 2 Quick-and-dirty
addAdvert
addAdvertUI
CampaignManager
startInterface
selectClient
asynchronous message
18
Collaboration Diagram
  • Shows the messages sent between objects without
    the linear order shown in a sequence diagram.
  • Concentrates on the collaborations between
    objects.
  • Better than sequence diagrams for illustrating
    complex branching, iteration, and concurrent
    behaviour.

19
Example - Collaboration Diagram 1
Scenario Register payment of a sale
direction of message
first internal message
1 makePayment(cashTendered)
makePayment(cashTendered)
Register
Sale
link line
1.1 create(cashTendered)
first message
parameter
Payment
creation indicated with a
instance
"create" message
Ref Larman
20
Collaboration Diagram Notation
  • Links
  • Messages
  • Messages to self or this
  • Creation of instances
  • Message Number Sequencing
  • Conditional messages
  • Iteration or looping

21
Example - Collaboration Diagram 2
Scenario Add a new advert to a campaign
Client is responsible for providing data about
campaigns to AddAdvert
Bennett, Figure 9.13
22
Example - Collaboration Diagram 3
Can show different possible allocations of
responsibility
Scenario Add a new advert to a campaign
Here Client is responsible for providing
AddAdvert with a list of its campaigns. AddAdvert
is now responsible for getting campaign details
directly from Campaign objects.
Bennett, Figure 9.14
Write a Comment
User Comments (0)
About PowerShow.com