Download - Lecture07
Computer Engineering Department
Computer Engineering Department
Object Oriented Software Modeling and Design
CE 350Abdel-Karim Al-Tamimi, Ph.D.
[email protected]://faculty.yu.edu.jo/
altamimi
Al-Tamimi 2011 © 1
Overview
• Interaction Diagrams:– Sequence Diagram– Collaboration Diagram
Al-Tamimi 2011 © 2
Interaction Diagrams
• Scenario modeling describes how the objects in a system interact with each other in a scenario
• A scenario is a sequence of events that occurs during one particular execution path within a use case of a system
• Each event involves the interaction of objects passing messages between them
Al-Tamimi 2011 © 3
Interaction Diagrams• An interaction diagram can be used to model the
collaborating objects in scenarios, showing the – objects involved in the scenario and – the messages sent and received by them
• These objects may be external or internal to the system
• The messages represent the invocation of operations of the receiving objects
• Two kinds of interaction diagrams: sequence diagrams and collaboration diagrams
• Sequence diagrams focus on the time sequencing of messages
• Collaboration diagrams focus on the structural organization of the links between collaborating objects
Al-Tamimi 2011 © 4
Interaction in UML
• Interaction diagram: models the behavior of a group of objects that work together to achieve a user goal
• An interaction describes a series of messages that a selected set of participants exchange within a situation limited in time
• The entire diagram represents one interaction, but can be using several messages
Al-Tamimi 2011 © 5
Sequence Diagram
• Sequence diagrams emphasize the sequence in which messages are exchanged
• A sequence diagram helps us identify a set of collaborating objects involved in a scenario of a use case
• A sequence diagram has two dimensions: the vertical dimension and the horizontal dimension
• Object icons are placed horizontally at the top of the sequence diagram, and messages are passed between them
Al-Tamimi 2011 © 6
Sequence Diagram: Example
Al-Tamimi 2011 © 7
Sequence Diagram: Example
Al-Tamimi 2011 © 8
Naming Format Notation
An object of an unspecified class.
A named object of a specified class.
An unnamed object of a specified class.
Interaction Diagrams Notation in UML
Al-Tamimi 2011 © 9
Interaction Diagrams Notations in UML
Al-Tamimi 2011 © 10
Object Category
Description Graphical Notations
Actor Object An external entity that interacts with the system
Entity Object
An object that models the data in the system. It often represents an object in the problem domain
Interaction Diagrams Notations in UML
Al-Tamimi 2011 © 11
Object Category
Description Graphical Notations
Boundary Object
An object that handles the communication between actor objects and the system.
Control Object
An object that models the flow of control and functionality that do not naturally belong to entity objects or boundary objects.
UML Notations - Messages
Al-Tamimi 2011 © 12
Message Description Notation
Procedure call or other nested flow of control
The message sender waits for the completion of the procedure call of the message receiver (waits for a reply)
Asynchronous communication
The sender dispatches a message and immediately continues with the next step of execution (there are no reply arrows)
UML Notations - Messages
Al-Tamimi 2011 © 13
Message Description Notation
Return message
Message returned from the procedure call
Message with travel delay
The message will take a significant amount of time to arrive at the receiving object. (This is only used in sequence diagrams.)
UML Notations - Messages
Al-Tamimi 2011 © 14
Message Description Notation
Lost Message The sender is known, the receiver is not
Found Message
The sender is unknown, and the receiver is known
Create Message A message creates a new instance
Messages Notations Summary
Al-Tamimi 2011 © 15
Sequence Diagram: Lifeline and Activation
Al-Tamimi 2011 © 16
Object withLifeline
Object withActivation
Activation: show the duration of the execution of a method inresponse to a message
Sequence Diagram: Branching
Al-Tamimi 2011 © 17
ConditionalMessage
Transmission
Sequence Diagram: Iteration
Al-Tamimi 2011 © 18
Sequence Diagram: Alternate Message
Reception
Al-Tamimi 2011 © 19
Sequence Diagram: Recursion
Al-Tamimi 2011 © 20
Example
Al-Tamimi 2011 © 21
Life line
Creation
Deletion
Example
Al-Tamimi 2011 © 22
Life line Activatio
n
iteration
Example
Al-Tamimi 2011 © 23
Life linecollective iteration
Example
Al-Tamimi 2011 © 24
Concurrent Branch
Example
Al-Tamimi 2011 © 25
Example
Al-Tamimi 2011 © 26
Example
Al-Tamimi 2011 © 27
Tips and Tricks: Return Type
• Two ways to show return type of a message
Al-Tamimi 2011 © 28
Tips and Tricks: Object Destruction
Al-Tamimi 2011 © 29
Tips and Tricks: Iteration (looping) with A Condition
Al-Tamimi 2011 © 30
Tips and Tricks: Optional/Conditional
Messages
Al-Tamimi 2011 © 31
Tips and Tricks: Conditional Messages (Mutual
Exclusive)
Al-Tamimi 2011 © 32
Tips and Tricks: Looping Using Explicit Notations
Al-Tamimi 2011 © 33
Tips and Tricks: Looping Using Implicit Notations
Al-Tamimi 2011 © 34
Tips and Tricks: Nesting of Frames
Al-Tamimi 2011 © 35
Tips and Tricks: Relating Interaction Diagrams (Using Ref) / Interaction
Occurrence
Al-Tamimi 2011 © 36
Tips and Tricks: Polymorphic Message
Al-Tamimi 2011 © 37
Tips and Tricks: State Invariant
Al-Tamimi 2011 © 38
Tips and Tricks: State Invariant
Al-Tamimi 2011 © 39
Tips and Tricks: Parallel
Al-Tamimi 2011 © 40
Tips and Tricks: Negative Operator/Invalid Operation
Al-Tamimi 2011 © 41
Tips and Tricks: Critical Region/Atomic
Al-Tamimi 2011 © 42
Tips and Tricks: Decomposition
Al-Tamimi 2011 © 43
Tips and Tricks: Continuations
Al-Tamimi 2011 © 44
Tips and Tricks: Continuations
Al-Tamimi 2011 © 45
Tips and Tricks: Hard Timing Requirements
Al-Tamimi 2011 © 46
Tips and Tricks: Break Fragment
Al-Tamimi 2011 © 47
Collaboration Diagram• Collaboration diagrams provide another way to
model a scenario.• Shows the roles of objects and associations of
objects in an instance of collaboration• Focus on structures of the objects rather than
temporal sequence of operations• In a collaboration diagram, each object is
represented by an object icon, and links are used to indicate communication paths on which messages are transmitted
• Messages are presented in the same way as those in a sequence diagram; in fact, sequence diagrams and collaboration diagrams are semantically equivalent
Al-Tamimi 2011 © 48
Example: Telephone System
Al-Tamimi 2011 © 49
Example: Message with Durations
Al-Tamimi 2011 © 50
Example: Printing Transcripts
Al-Tamimi 2011 © 51
Example: Printing Transcripts
Al-Tamimi 2011 © 52
Example: from Java IO API
Al-Tamimi 2011 © 53
Example: ATM Machine The ATM prompts the user to insert a card The user inserts an ATM card The ATM prompts the user to input the PIN The user enters the PIN The ATM asks the bank consortium to verify the ATM
card number and PIN The bank consortium verifies the ATM card number and
PIN with bank The bank notifies the bank consortium that the PIN is
correct The bank consortium notifies the ATM the PIN is correct The ATM prompts the user to select a service The user selects the withdraw cash service The ATM prompts the user to enter the amount to
withdraw
Al-Tamimi 2011 © 54
Example: ATM Machine The user enters the amount to withdraw. The ATM asks the bank consortium to
process the request. The bank consortium forwards the request to bank.
The bank confirms the successful execution of the request to the bank consortium which in turn notifies the ATM that the request has been approved
The ATM displays the successful transaction screen, ejects card and then dispenses cash requested
The ATM shows the main menu to the user for selecting the next service
Al-Tamimi 2011 © 55
ATM Machine: Part1
Al-Tamimi 2011 © 56
ATM Machine-Part2
Al-Tamimi 2011 © 57
Soft-Drink Vending MachineSequence Diagram
Al-Tamimi 2011 © 58
Soft-Drink Vending MachineCollaboration Diagram
Al-Tamimi 2011 © 59
Example
Al-Tamimi 2011 © 60
Resources
• Chapter 4, Object-Oriented Technology: From diagram to code with Visual Paradigm for UML
• UML 2 Certification Guide• http://www.informit.com/articles/article.as
px?p=360441&seqNum=5• UML-2 in a nutshell, chapter 10• http://www.tracemodeler.com/gallery/• http://www.agilemodeling.com/artifacts/
communicationDiagram.htmAl-Tamimi 2011 © 61