Docsity

Understanding Sequence Diagrams in UML: Object Interactions and Messages, Slides of Object Oriented Analysis and Design

Partial preview of the text

Download Understanding Sequence Diagrams in UML: Object Interactions and Messages and more Slides Object Oriented Analysis and Design in PDF only on Docsity!

Sequence Diagrams

Sequence Diagrams 2

Agenda

  • Interaction Diagrams
  • A First Look at Sequence Diagrams
  • Objects
  • Messages
  • Control Information
  • Examples

Sequence Diagrams 4

Interaction Diagrams (Cont.)

  • The purpose of Interaction diagrams is to:
    • Model interactions between objects
    • Assist in understanding how a system (a use case) actually works
    • Verify that a use case description can be supported by the existing classes
    • Identify responsibilities/operations and assign them to classes

Sequence Diagrams 5

Interaction Diagrams (Cont.)

  • UML
    • Collaboration Diagrams
      • Emphasizes structural relations between objects
    • Sequence Diagram
      • The subject of this tutorial

Sequence Diagrams 7

A Sequence Diagram

member: LibraryMember book:Book^

:Book Copy

borrow(book) ok = mayBorrow()

[ok] borrow(member) setTaken(member)

Sequence Diagrams 8

A Sequence Diagram

member: LibraryMember book:Book^

:Book Copy

borrow(book) ok = mayBorrow()

[ok] borrow(member) (^) setTaken(member)

X-Axis (objects)

Y-Axis (time)^ Life^ Object

message Line Activation box condition

Sequence Diagrams 10

Messages

  • An interaction between two objects is

performed as a message sent from one

object to another (simple operation call,

Signaling, RPC)

  • If object obj 1 sends a message to another

object obj 2 some link must exist between

those two objects

Sequence Diagrams 11

Messages (Cont.)

  • A message is represented by an arrow between the

life lines of two objects.

  • Self calls are also allowed
  • The time required by the receiver object to process the message is denoted by an activation-box.
  • A message is labeled at minimum with the

message name.

  • Arguments and control information (conditions, iteration) may be included.

Sequence Diagrams 13

Synchronous Messages

  • Nested flow of control, typically

implemented as an operation call.

  • The routine that handles the message is completed before the caller resumes execution.

:A :B

doYouUnderstand()

Caller Blocked

return yes^ (optional)

Sequence Diagrams 14

Object Creation

  • An object may create another object via a

<> message.

:A :B

<>

Constructor

:A

<> (^) :B

Preferred

Sequence Diagrams 16

Control information

  • Condition
    • syntax: โ€˜[โ€˜ expression โ€™]โ€™ message-label
    • The message is sent only if the condition is true
    • example:
  • Iteration
    • syntax: * [ โ€˜[โ€˜ expression โ€˜]โ€™ ] message-label
    • The message is sent many times to possibly multiple receiver objects.

[ok] borrow(member)

Sequence Diagrams 17

Control Information (Cont.)

  • Iteration examples:

:Driver

*[until full] insert()

:Bus

The syntax of expressions is not a standard

:CompoundShape :Shape draw() *draw()

Sequence Diagrams 19

getViolation(id)

Example 1

Clerk

:Violations Dialog

:Violations Controller

:Violations DBProxy

lookup (^) viewButton()

id=getID()

v:Traffic Violation

display(v)

<>

v

Lookup Traffic Violation

DB is queried and the result is returned as an object

Sequence Diagrams 20

Example 2 - Observer Pattern

??? : ConcreteSubject ob1 : ConcreterObserver ob2 : ConcreterObserver notify( ) update( ) getState( ) update( ) getState( )

for eachobserver