Date post: | 30-May-2018 |
Category: |
Documents |
Upload: | thanhluantink30c |
View: | 225 times |
Download: | 0 times |
of 26
8/14/2019 UML Behavioral Modeling 2
1/26
University
Hue UniversityHue University
UML INTERACTIONUML INTERACTION
DIAGRAMSDIAGRAMS . , Dr Hoang Huu Hanh OST Hue University
hanh-at-hueuni.edu.vn
8/14/2019 UML Behavioral Modeling 2
2/26
10/29/09 2
University
ObjectivesObjectives
Read basic UML Interaction(communication and Sequence)Diagram notation
8/14/2019 UML Behavioral Modeling 2
3/26
3
University
IntroductionIntroduction
Why do objects exist?To perform an activity to help fulfill
a systems purpose
Interaction Diagrams are used tomodel system dynamics How do objects change state?
How do objects interact (messagepassing)?
8/14/2019 UML Behavioral Modeling 2
4/26
4
University
Communication & SequenceCommunication & SequenceDiagramsDiagramsAn Interaction Diagram is a
generalization of two specializedUML diagram types
Communication Diagrams:
Illustrate object interactionsorganized around the objects andtheir links to each other
Sequence Diagrams: Illustrateobject interactions arranged intime sequence
8/14/2019 UML Behavioral Modeling 2
5/26
5
University
Communication & SequenceCommunication & Sequence
Diagrams (2)Diagrams (2)
Both diagram types aresemantically equivalent,however, they may not show the
same information Communication Diagrams
emphasize the structuralorganization of objects, while
Sequence Diagrams emphasizethe time ordering of messages
Communication Diagrams explicitlyshow object linkages, while linksare implied in Sequence Diagrams
8/14/2019 UML Behavioral Modeling 2
6/26
6
University
Interaction Diagrams AreInteraction Diagrams Are
ValuableValuableInteraction Diagrams provide a
thoughtful, cohesive, commonstarting point for inspiration
during programmingPatterns, principles, and idioms
can be applied to improve the
quality of the InteractionDiagrams
8/14/2019 UML Behavioral Modeling 2
7/267
University
Common Interaction DiagramCommon Interaction Diagram
NotationNotation
class instance named instance
:Sale s1:SaleSale
8/14/2019 UML Behavioral Modeling 2
8/268
University
Communication DiagramsCommunication Diagrams
Objects are connected with numbered(sequenced) arrows along links todepict information flow
Arrows are drawn from the interaction
sourceThe object pointed to by the arrow is
referred to as the targetArrows are numbered to depict their
usage order within the scenarioArrows are labeled with the passed
message
8/14/2019 UML Behavioral Modeling 2
9/269
University
Example CommunicationExample Communication
DiagramDiagram
:ClassAInstance
:ClassBInstance
1:message1()
2:message2()
message1()
8/14/2019 UML Behavioral Modeling 2
10/26
8/14/2019 UML Behavioral Modeling 2
11/2611
University
Basic CommunicationBasic Communication
Diagram NotationDiagram NotationLink - connection path between
two objects (an instance of anassociation)
Message - represented with amessage expression on anarrowed line between objects
Sequence Number - representsthe order in which the flows areused
8/14/2019 UML Behavioral Modeling 2
12/2612
University
Basic CommunicationBasic Communication
Diagram Notation (2)Diagram Notation (2)Conditional Message
Seq. Number [ variable = value ] :message()
Message is sent only if clauseevaluates to true
Iteration (Looping)
Seq. Number * [ i := 1..N ]:
message()
* is required; [ ... ] clause isoptional
8/14/2019 UML Behavioral Modeling 2
13/2613
University
Sequence DiagramsSequence Diagrams
Correspond to one scenario within aUse Case
Model a single operation within aSystem over time
Identify the objects involved with eachscenario
Identify the passed messages and
actions that occur during a scenarioIdentify the required response of each
action
8/14/2019 UML Behavioral Modeling 2
14/2614
University
Example SequenceExample SequenceDiagramDiagram
:ClassAInstance :ClassBInstance
message1()
message2()
message1()
8/14/2019 UML Behavioral Modeling 2
15/2615
University
Example SequenceExample Sequence
Diagram: make PaymentDiagram: make Payment
:Register :Sale
:Payment
an activation box showing the focus of control
makePayment(cashTendered:)
create(cashTendered:)
makePayment(cashTendered:)
X
8/14/2019 UML Behavioral Modeling 2
16/2616
University
Basic Sequence DiagramBasic Sequence Diagram
NotationNotationLinks - Sequence Diagrams do not
show links
Message - represented with a
message expression on anarrowed line between objects
8/14/2019 UML Behavioral Modeling 2
17/2617
University
Basic Sequence DiagramBasic Sequence DiagramNotation (2)Notation (2)
Object Lifeline - the verticaldashed line underneath anobject
Objects do not have a lifeline untilthey are created
The end of an objects life ismarked with an X at the end of
the lifeline Passage of time is from top to
bottom of diagram
8/14/2019 UML Behavioral Modeling 2
18/26
18
University
Basic Sequence DiagramBasic Sequence DiagramNotation (3)Notation (3)
Activation - the period of time anobject is handling a message(box along lifeline)
Activation boxes can be overlaid todepict an object invoking anothermethod on itself
8/14/2019 UML Behavioral Modeling 2
19/26
19
University
Basic Sequence DiagramBasic Sequence DiagramNotation (4)Notation (4)
Conditional Message [ variable = value ] message()
Message is sent only if clause
evaluates to trueIteration (Looping)
* [ i := 1..N ]: message()
* is required; [ ... ] clause isoptional
8/14/2019 UML Behavioral Modeling 2
20/26
20
University
Interaction DiagramInteraction DiagramStrengthsStrengthscommunication Diagram
Space Economical - flexibility to addnew objects in two dimensions
Better to illustrate complexbranching, iteration, andconcurrent behavior
Sequence Diagram
Clearly shows sequence or timeordering of messages
Simple notation
8/14/2019 UML Behavioral Modeling 2
21/26
21
University
Interaction DiagramInteraction DiagramWeaknessesWeaknessesCommunication Diagram
Difficult to see sequence ofmessages
More complex notationSequence Diagram
Forced to extend to the right whenadding new objects; consumes
horizontal space
8/14/2019 UML Behavioral Modeling 2
22/26
University
ATM ClientATM ClientCollaboration Diagram for Validate PIN UseCase
8/14/2019 UML Behavioral Modeling 2
23/26
UniversityUniversity
8/14/2019 UML Behavioral Modeling 2
24/26
University
ATM ClientATM ClientSequence Diagram for Validate PIN UseCase
8/14/2019 UML Behavioral Modeling 2
25/26
UniversityUniversity
8/14/2019 UML Behavioral Modeling 2
26/26
26
University
ConclusionsConclusions
Beginners in UML oftenemphasize Class Diagrams.Interaction Diagrams usually
deserve more attention.There is no rule about which
diagram to use. Both are oftenused to emphasize the flexibilityin choice and to reinforce thelogic of the operation. Sometools can convert one to the
other automatically