An Introduction to UML Interaction Sequence and Communication

  • Slides: 28
Download presentation
An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300

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

Models, Views, and Diagrams Use Case Diagrams Sequence Diagrams Use Case Diagrams State Diagrams

Models, Views, and Diagrams Use Case Diagrams Sequence Diagrams Use Case Diagrams State Diagrams Class Diagrams Scenario Diagrams Communication Diagrams Scenario Diagrams State Machine Diagrams Models A model is a complete description of a system from a particular perspective State Diagrams Object Diagrams State Diagrams Component Diagrams Deployment Diagrams Activity Diagrams

Behavioral Diagrams Used to visualize, specify, construct, document dynamic aspects of system: n use

Behavioral Diagrams Used to visualize, specify, construct, document dynamic aspects of system: n use case diagram sequence diagram n communication diagram n n n state machine diagram activity diagram 3

Diagramming Scenarios: UML ways of expressing scenarios n Activity diagrams n n n Several

Diagramming Scenarios: UML ways of expressing scenarios n Activity diagrams n n n Several scenarios (even a full use case) at once Similar to Petri nets, Graphcet, (concurrent) flow charts… Interaction (sequence and communication) diagrams n n n Only one scenario per diagram Involve/introduce (high level) objects Sequence diagram n n Accent on the time flow Communication diagram n Accent on the messages between objects 4

Interaction Diagrams (Sequence and Communication) n Describe how groups of objects collaborate in some

Interaction Diagrams (Sequence and Communication) n Describe how groups of objects collaborate in some behavior n Sequence diagrams n n Time-oriented Communication diagrams n Message-oriented 5

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

Diagramming Scenarios: Sequence Diagrams n n Describe one scenario Involve objects and messages n n Shows a number of objects and the messages that are passed between these objects. Accent is on the time flow of events 6

Diagramming Scenarios: Sequence Diagrams n Simple scenario: We have an order and are going

Diagramming Scenarios: Sequence Diagrams n Simple scenario: 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 the order and determine their prices, which are based on the pricing rules of the order’s line products. Having done that for all the line items, the order then needs to compute an overall discount, which is based on rules tied to the customer. 7

Sequence Diagrams n UML 1. 0 versus UML 2. 0: n n Objects pass

Sequence Diagrams n UML 1. 0 versus UML 2. 0: n n Objects pass messages (UML 1. 0) Participants pass messages (UML 2. 0) Show participants (objects) interact. Differences in interaction styles: n n 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. 10

Diagramming Scenarios: Sequence Diagrams (cont. ) ATM Customer insert_card Bank « new » display_menu()

Diagramming Scenarios: Sequence Diagrams (cont. ) ATM Customer insert_card Bank « new » display_menu() select_transaction(sel) Session get_Customer_Information() « new » Transaction display_menu() quit card_returned time eject_card_taken 11

Interaction and Message An interaction is a behavior that comprises a set of messages,

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

Sequence Diagram A sequence diagram is an interaction diagram that emphasizes the time ordering

Sequence Diagram A 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. 13

Sequence Diagram Notation 14

Sequence Diagram Notation 14

Sequence Diagram Notation 15

Sequence Diagram Notation 15

Sequence Diagram Notation 16

Sequence Diagram Notation 16

Sequence Diagram n n Captures dynamic behavior (timeoriented) Purpose n n Model flow of

Sequence Diagram n n Captures dynamic behavior (timeoriented) Purpose n n Model flow of control Illustrate typical scenarios 17

18

18

UML Sequence Diagrams Passenger Ticket. Machine select. Zone() n Used during requirements analysis n

UML Sequence Diagrams Passenger Ticket. Machine select. Zone() n Used during requirements analysis n n insert. Coins() n Used during system design n n pickup. Change() n n pick. Up. Ticket() n To refine use case descriptions to find additional objects (“participating objects”) 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

UML Sequence Diagrams: Nested Messages Passenger Zone. Button select. Zone() Tarif. Schedule Display lookup.

UML Sequence Diagrams: Nested Messages Passenger Zone. Button select. Zone() Tarif. Schedule Display lookup. Price(selection) price Dataflow display. Price(price) …to be continued. . . n n The source of an arrow indicates the activation which sent the message An activation is as long as all nested activations

Sequence Diagram Observations n n UML sequence diagram represent behavior in terms of interactions.

Sequence Diagram Observations n n 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. 21

Diagramming Scenarios: Communication Diagrams n n Describe one scenario Involve objects and messages Accent

Diagramming Scenarios: Communication Diagrams n n Describe one scenario Involve objects and messages Accent is on messages exchanged between objects Sequence and Communication diagrams are largely equivalent. 22

Diagramming Scenarios: Communication Diagrams (cont. ) : Customer 1: insert_card 7: card_taken : Bank

Diagramming Scenarios: Communication Diagrams (cont. ) : Customer 1: insert_card 7: card_taken : Bank 4: select_transaction 3: get_customer_information : ATM 2: « create » 6: eject_card : Session 5: « create » : Transaction 23

Communication Diagram A communication diagram is an interaction diagram that emphasizes the organization of

Communication Diagram A 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. 24

Communication Diagram n n Captures dynamic behavior (messageoriented) Purpose n n Model flow of

Communication Diagram n n Captures dynamic behavior (messageoriented) Purpose n n Model flow of control Illustrate coordination of object structure and control 25

Communication Diagram Notation 26

Communication Diagram Notation 26

Communication Diagram Notation 27

Communication Diagram Notation 27

28

28