lecture07

61
Computer Engineering Department Object Oriented Software Modeling and Design CE 350 Abdel-Karim Al-Tamimi, Ph.D. [email protected] http:// faculty.yu.edu.jo/ altamimi Al-Tamimi 2011 © 1

Upload: artgreen

Post on 06-May-2015

2.604 views

Category:

Education


1 download

DESCRIPTION

Interaction Diagrams: Sequence and Collaboration Diagrams

TRANSCRIPT

Page 1: 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

Page 2: Lecture07

Overview

• Interaction Diagrams:– Sequence Diagram– Collaboration Diagram

Al-Tamimi 2011 © 2

Page 3: Lecture07

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

Page 4: Lecture07

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

Page 5: Lecture07

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

Page 6: Lecture07

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

Page 7: Lecture07

Sequence Diagram: Example

Al-Tamimi 2011 © 7

Page 8: Lecture07

Sequence Diagram: Example

Al-Tamimi 2011 © 8

Page 9: Lecture07

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

Page 10: Lecture07

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

Page 11: Lecture07

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.

Page 12: Lecture07

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)

Page 13: Lecture07

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.)

Page 14: Lecture07

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

Page 15: Lecture07

Messages Notations Summary

Al-Tamimi 2011 © 15

Page 16: Lecture07

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

Page 17: Lecture07

Sequence Diagram: Branching

Al-Tamimi 2011 © 17

ConditionalMessage

Transmission

Page 18: Lecture07

Sequence Diagram: Iteration

Al-Tamimi 2011 © 18

Page 19: Lecture07

Sequence Diagram: Alternate Message

Reception

Al-Tamimi 2011 © 19

Page 20: Lecture07

Sequence Diagram: Recursion

Al-Tamimi 2011 © 20

Page 21: Lecture07

Example

Al-Tamimi 2011 © 21

Life line

Creation

Deletion

Page 22: Lecture07

Example

Al-Tamimi 2011 © 22

Life line Activatio

n

iteration

Page 23: Lecture07

Example

Al-Tamimi 2011 © 23

Life linecollective iteration

Page 24: Lecture07

Example

Al-Tamimi 2011 © 24

Concurrent Branch

Page 25: Lecture07

Example

Al-Tamimi 2011 © 25

Page 26: Lecture07

Example

Al-Tamimi 2011 © 26

Page 27: Lecture07

Example

Al-Tamimi 2011 © 27

Page 28: Lecture07

Tips and Tricks: Return Type

• Two ways to show return type of a message

Al-Tamimi 2011 © 28

Page 29: Lecture07

Tips and Tricks: Object Destruction

Al-Tamimi 2011 © 29

Page 30: Lecture07

Tips and Tricks: Iteration (looping) with A Condition

Al-Tamimi 2011 © 30

Page 31: Lecture07

Tips and Tricks: Optional/Conditional

Messages

Al-Tamimi 2011 © 31

Page 32: Lecture07

Tips and Tricks: Conditional Messages (Mutual

Exclusive)

Al-Tamimi 2011 © 32

Page 33: Lecture07

Tips and Tricks: Looping Using Explicit Notations

Al-Tamimi 2011 © 33

Page 34: Lecture07

Tips and Tricks: Looping Using Implicit Notations

Al-Tamimi 2011 © 34

Page 35: Lecture07

Tips and Tricks: Nesting of Frames

Al-Tamimi 2011 © 35

Page 36: Lecture07

Tips and Tricks: Relating Interaction Diagrams (Using Ref) / Interaction

Occurrence

Al-Tamimi 2011 © 36

Page 37: Lecture07

Tips and Tricks: Polymorphic Message

Al-Tamimi 2011 © 37

Page 38: Lecture07

Tips and Tricks: State Invariant

Al-Tamimi 2011 © 38

Page 39: Lecture07

Tips and Tricks: State Invariant

Al-Tamimi 2011 © 39

Page 40: Lecture07

Tips and Tricks: Parallel

Al-Tamimi 2011 © 40

Page 41: Lecture07

Tips and Tricks: Negative Operator/Invalid Operation

Al-Tamimi 2011 © 41

Page 42: Lecture07

Tips and Tricks: Critical Region/Atomic

Al-Tamimi 2011 © 42

Page 43: Lecture07

Tips and Tricks: Decomposition

Al-Tamimi 2011 © 43

Page 44: Lecture07

Tips and Tricks: Continuations

Al-Tamimi 2011 © 44

Page 45: Lecture07

Tips and Tricks: Continuations

Al-Tamimi 2011 © 45

Page 46: Lecture07

Tips and Tricks: Hard Timing Requirements

Al-Tamimi 2011 © 46

Page 47: Lecture07

Tips and Tricks: Break Fragment

Al-Tamimi 2011 © 47

Page 48: Lecture07

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

Page 49: Lecture07

Example: Telephone System

Al-Tamimi 2011 © 49

Page 50: Lecture07

Example: Message with Durations

Al-Tamimi 2011 © 50

Page 51: Lecture07

Example: Printing Transcripts

Al-Tamimi 2011 © 51

Page 52: Lecture07

Example: Printing Transcripts

Al-Tamimi 2011 © 52

Page 53: Lecture07

Example: from Java IO API

Al-Tamimi 2011 © 53

Page 54: Lecture07

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

Page 55: Lecture07

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

Page 56: Lecture07

ATM Machine: Part1

Al-Tamimi 2011 © 56

Page 57: Lecture07

ATM Machine-Part2

Al-Tamimi 2011 © 57

Page 58: Lecture07

Soft-Drink Vending MachineSequence Diagram

Al-Tamimi 2011 © 58

Page 59: Lecture07

Soft-Drink Vending MachineCollaboration Diagram

Al-Tamimi 2011 © 59

Page 60: Lecture07

Example

Al-Tamimi 2011 © 60

Page 61: Lecture07

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