Sequence diagrams - School of Engineering and Information

advertisement
ZEIT2301
Design of Information Systems
Interaction Design:
Sequence Diagrams
School of Engineering and Information Technology
UNSW@ADFA
Dr Kathryn Merrick
Topic 07: Interaction Design

Objectives

To discuss the role of interaction diagrams in IS development.

To understand the notation, rules and style guidelines for creating
interaction diagrams:
 Today we will look at sequence diagrams
 Tomorrow we will look at communication diagrams
Reference: Text Ch 7
2
Interaction Diagrams

Sequence and communication diagrams represent how
objects collaborate to support business processes
portrayed by use cases
3
Sequence Diagrams

Sequence diagrams illustrate the objects that participate in a Use
Case

Show the messages that pass between objects over time for a
particular Use Case

Typically one sequence diagram is produced for each scenario in a
use case

may sometimes produce a sequence diagram showing all possible
scenarios.
4
Sequence Diagrams

Elements of a sequence diagram:

Actors & Objects

Lifeline – represents time passing


Sometimes an object creates a temporary object - an “X”
is placed at the point in the lifeline that the object is
destroyed, e.g. shopping cart.
Execution occurrence – overlaid onto an object’s lifeline to show
when the object is activated
5
Sequence Diagrams

Elements of a sequence diagram (continued):

Message – a communication between objects.

Types (used in sequence diagrams):




Operation call message
Return message Note: unless a return message
adds information, it should be omitted
Sequence – order of messages is top to bottom
Conditions [ ] – message is sent only if condition is true, e.g. [aPatient
Exists] LookupBills ()

where “aPatient” represents an object of the Class Patient
6
Sequence Diagram: Notation
7
Sequence Diagram: Notation
8
Sequence Diagram Example
Session 2, 2010
9
Sequence Diagram - Rent Movie
:CheckoutMgr
:Customer
:Inventory
:RentedItems
Employee
:
find customer()
enter movie()
search (string)
search (string)
Object
Activation
Message
rent (movie)
add(Cust, item)
Lifeline
printInvoice()
Session 2, 2010
generateRentalTotal()
The notation “:Inventory” means an anonymous
object of class Inventory.
10
Sequence Diagram:
Places Order Use case
Session 2, 2010
11
These “temporary” objects can now cease to exist
Sequence Diagrams versus
Class Diagrams

The messages identified in your Sequence Diagram, then
become operations in the Class Diagram.

If the aCustomer:Customer object sends a message
“createSR()” to the aSR:SearchRequest object then the
class SearchRequest should have an operation
createSR()

Note that the requested operation belongs to the recipient
of the message.
12
Sequence Diagram and Class
Diagram Example
searchRequest
Customer
studentID
name
updateAddress()
.....
requests
1..1
0..*
searchNo
searchTerm
.....
createSR()
....
Message from Sequence Diagram becomes an operation in the
Class Diagram. Operation belongs with the recipient of the
message.
Session 2, 2010
13
Summary

After today’s lecture you should be able to:

Construct sequence diagrams

Use sequence diagrams to inform the design of class
diagrams
14
Download