Object Diagram Interaction Diagrams
Unified Modeling Language (UML) Object Diagram and Interaction Diagrams
Miaoqing Huang University of Arkansas Spring 2010
1 / 17 Object Diagram Interaction Diagrams Outline
1 Object Diagram
2 Interaction Diagrams Sequence Diagram Communication Diagram
2 / 17 Object Diagram Interaction Diagrams Outline
1 Object Diagram
2 Interaction Diagrams Sequence Diagram Communication Diagram
3 / 17 Object Diagram Interaction Diagrams Object Diagram A snapshot of the objects in a system at a point in time Object: instance of a class Notation Object name is underlined instance name : class name Both parts of the name are optional
EndsAt StartsAt
StartsAt EndsAt
4 / 17 Object Diagram Sequence Diagram Interaction Diagrams Communication Diagram Outline
1 Object Diagram
2 Interaction Diagrams Sequence Diagram Communication Diagram
5 / 17 Object Diagram Sequence Diagram Interaction Diagrams Communication Diagram UML Diagrams
Class Object Use Case Diagram Diagram Diagram
Sequence Communication Diagram Diagram
6 / 17 Object Diagram Sequence Diagram Interaction Diagrams Communication Diagram Purpose of Sequence Diagram
Static diagram Use case diagrams show the static relationship between actors and use cases Class diagrams show the static relationship between classes or instances A program is a sequence of interactions among objects (i.e., instances of classes) Difficult of find a program only with static diagrams Purpose of sequence diagram Model the high-level interaction between active objects in a system Model the high-level interaction between subsystems
7 / 17 Object Diagram Sequence Diagram Interaction Diagrams Communication Diagram Sequence Diagram Example
sd Create new agreement
:RecordAgreement :RecordAgreement first:CarSharer :Journey UI Control CarMatch Administrator new agreement details set create sharing agreement :SharingAgreement
loop [i=1..no of car sharers] get car sharer ID
find by ID
get journey ID
find by ID
add journey set sharing agreement
set first arranged
8 / 17 Object Diagram Sequence Diagram Interaction Diagrams Communication Diagram Notation Frame
sd Create new agreement
:RecordAgreement :RecordAgreement first:CarSharer :Journey UI Control CarMatch Administrator new agreement details set create sharing agreement :SharingAgreement
loop [i=1..no of car sharers] get car sharer ID
find by ID
get journey ID
find by ID
add journey set sharing agreement
set first arranged
Sequence diagrams are Time runs vertically drawn in frames Lifelines are arranged New in UML 2.0 horizontally Represent object instances
9 / 17 Object Diagram Sequence Diagram Interaction Diagrams Communication Diagram Notation Frame
sd Create new agreement
:RecordAgreement :RecordAgreement first:CarSharer :Journey UI Control CarMatch Administrator new agreement details set create sharing agreement :SharingAgreement
loop [i=1..no of car sharers] get car sharer ID
find by ID
get journey ID
find by ID
add journey set sharing agreement
set first arranged
Sequence diagrams are Time runs vertically drawn in frames Lifelines are arranged New in UML 2.0 horizontally Represent object instances
10 / 17 Object Diagram Sequence Diagram Interaction Diagrams Communication Diagram Notation Lifeline
Participating instances are represented by lifelines Dashed vertical line Rectangle representing an object
Syntax Explanation o An object named o o : C An object named o of class C :C An anonymous object of class C
11 / 17 Different types of messages Synchronous Asynchronous Creation Reply
Object Diagram Sequence Diagram Interaction Diagrams Communication Diagram Notation Messages and Activation box
A message is shown using an arrow going from the sender to the receiver The activation box indicate the active period of the object An object may have more than one active operation at the same time
12 / 17 Object Diagram Sequence Diagram Interaction Diagrams Communication Diagram Notation Messages and Activation box
A message is shown using an arrow going from the sender to the receiver The activation box indicate the active period of the object An object may have more than one active operation at the same time Different types of messages Synchronous Asynchronous Creation Reply
13 / 17 Object Diagram Sequence Diagram Interaction Diagrams Communication Diagram Sequence Diagram Example with Explicit Reply
sd Create new agreement
:RecordAgreement :RecordAgreement first:CarSharer :Journey UI Control CarMatch Administrator new agreement details set create sharing agreement :SharingAgreement
loop [i=1..no of car sharers] get car sharer ID
find by ID
get journey ID
find by ID
add journey set sharing agreement
set first arranged
14 / 17 Object Diagram Sequence Diagram Interaction Diagrams Communication Diagram Notation Combined Fragments
A sequence of messages can be combined into a fragment Loop, branches, ...
sd Create new agreement
:RecordAgreement :RecordAgreement first:CarSharer :Journey UI Control CarMatch Administrator new agreement details set create sharing agreement :SharingAgreement
loop [i=1..no of car sharers] get car sharer ID
find by ID
get journey ID
find by ID
add journey set sharing agreement
set first arranged
15 / 17 Object Diagram Sequence Diagram Interaction Diagrams Communication Diagram Communication Diagram Notation
Frame: same as sequence diagram Lifeline: almost same as sequence diagram, no dash line Link Use to link interacting objects
Message: almost same as sequence diagram Sequence-expression: message Recurrence in sequence-expression sent iteratively: *[iteration-clause] (e.g., *[i:0..journeys.length]) sent depending on some guard condition, e.g., [dataArranged = null]
16 / 17 Object Diagram Sequence Diagram Interaction Diagrams Communication Diagram Communication Diagram Example
sd Spool File to Printer
4: print(name)
:WordProcessor :PrintSpooler
1: open(name) 2: write(document) 4.1: open(name) 3: close 4.2*[while not eof]:readBlock 4.3: print(block) 4.3: close 4.4: delete(name) :PrinterFile
:Printer
17 / 17