1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University...

28
1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009

Transcript of 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University...

Page 1: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

1

An Introduction to UML Interaction (Sequence and Communication) Diagrams

Georgia State UniversityCIS 3300Spring, 2009

Page 2: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

Models, Views, and Diagrams

Use CaseDiagramsUse Case

DiagramsUse CaseDiagrams

ScenarioDiagramsScenario

DiagramsCommunicationDiagrams

StateDiagramsState

DiagramsComponentDiagrams

ComponentDiagramsComponent

DiagramsDeploymentDiagrams

StateDiagramsState

DiagramsObjectDiagrams

ScenarioDiagramsScenario

DiagramsState MachineDiagrams

Use CaseDiagramsUse Case

DiagramsSequenceDiagrams

StateDiagramsState

DiagramsClassDiagrams

ActivityDiagrams

A model is a completedescription of a systemfrom a particularperspective

Models

Page 3: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

3

Behavioral DiagramsUsed to visualize, specify, construct,document dynamic aspects of

system: use case diagram sequence diagram communication diagram state machine diagram activity diagram

Page 4: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

4

Diagramming Scenarios: UML ways of expressing scenarios Activity diagrams

Several scenarios (even a full use case) at once Similar to Petri nets, Graphcet, (concurrent)

flow charts… Interaction (sequence and communication)

diagrams Only one scenario per diagram Involve/introduce (high level) objects Sequence diagram

Accent on the time flow Communication diagram

Accent on the messages between objects

Page 5: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

5

Interaction Diagrams(Sequence and Communication)

Describe how groups of objects collaborate in some behavior Sequence diagrams

Time-oriented Communication diagrams

Message-oriented

Page 6: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

6

Diagramming Scenarios:Sequence Diagrams Describe one scenario Involve objects and messages

Shows a number of objects and the messages that are passed between these objects.

Accent is on the time flow of events

Page 7: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

7

Simple scenario:

Diagramming Scenarios:Sequence Diagrams

We have an order and are going to invoke a command on it to calculate its price. To do that, the order needs to look at all the line items on theorder and determine their prices, which are based on the pricing rulesof the order’s line products. Having done that for all the line items, theorder then needs to compute an overall discount, which is based onrules tied to the customer.

Page 8: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.
Page 9: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.
Page 10: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

10

Sequence Diagrams UML 1.0 versus UML 2.0:

Objects pass messages (UML 1.0) Participants pass messages (UML 2.0)

Show how participants (objects) interact. Differences in interaction styles:

Fig 4-1: Centralized, e.g. one participant does all the processing and other participants supply data.

Fig 4-2: Distributed, e.g. processing is split among many participants.

Page 11: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

11

Diagramming Scenarios:Sequence Diagrams (cont.)

get_Customer_Information()

select_transaction(sel)

display_menu()

quit

Customer Bank

time card_taken

eject_cardcard_returned

insert_card

ATM

Session« new »

Transaction« new »

display_menu()

Page 12: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

12

Interaction and Message

An interaction is a behavior that comprises a set of messages, exchanged among a set of objects, to accomplish a specific purpose.

A message is the specification of a communication between objects that conveys information, with the expectation that some kind of activity will ensue.

Page 13: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

13

Sequence DiagramA sequence diagram is an interaction diagram that emphasizes the time ordering of messages.A lifeline is a vertical dashed line that represents the lifetime of an object.A focus of control is a tall, thin rectangle that shows the period of time during which an object is performing an action.

Page 14: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

14

Sequence Diagram Notation

Page 15: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

15

Sequence Diagram Notation

Page 16: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

16

Sequence Diagram Notation

Page 17: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

17

Sequence Diagram

Captures dynamic behavior (time-oriented)

Purpose Model flow of control Illustrate typical scenarios

Page 18: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

18

Page 19: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

UML Sequence Diagrams

Used during requirements analysis

To refine use case descriptions to find additional objects

(“participating objects”) Used during system design

to refine subsystem interfaces Classes (and objects) are

represented by columns Messages are represented by

arrows Activations are represented by

narrow rectangles Lifelines are represented by

dashed lines

selectZone()

pickupChange()

pickUpTicket()

insertCoins()

PassengerTicketMachine

Page 20: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

UML Sequence Diagrams: Nested Messages

The source of an arrow indicates the activation which sent the message

An activation is as long as all nested activations

selectZone()

PassengerZoneButton TarifSchedule Display

lookupPrice(selection)

displayPrice(price)

price

Dataflow

…to be continued...

Page 21: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

21

Sequence Diagram Observations UML sequence diagram represent

behavior in terms of interactions. Complement the class diagrams

which represent structure. Useful to find participating objects. Time consuming to build but worth

the investment.

Page 22: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

22

Diagramming Scenarios:Communication Diagrams Describe one scenario Involve objects and messages Accent is on messages exchanged

between objects

Sequence and Communication diagrams are largely equivalent.

Page 23: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

23

Diagramming Scenarios:Communication Diagrams (cont.)

: Customer

: ATM

: Bank

: Session

: Transaction

1: insert_card

7: card_taken

4: select_transaction

3: get_customer_information

5: « create »

2: « create »

6: eject_card

Page 24: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

24

Communication DiagramA communication diagram is an interaction diagram that emphasizes the organization of the objects that participate in the interaction.A path is a link between objects, perhaps with a stereotype such as «local» attached.Sequence numbers indicate the time ordering of messages, to one or more levels.

Page 25: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

25

Communication Diagram

Captures dynamic behavior (message-oriented)

Purpose Model flow of control Illustrate coordination of object

structure and control

Page 26: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

26

Communication Diagram Notation

Page 27: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

27

Communication Diagram Notation

Page 28: 1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.

28