Seoc09 Notes
Seoc09 Notes
Massimo Felici
Massimo Felici
Communication Diagrams
c 20042011
Massimo Felici
Communication Diagrams
c 20042011
Rationale
Communication Diagrams
Model collaborations between objects or roles that deliver the functionalities of use cases and operations Model mechanisms within the architectural design of the system Capture interactions that show the passed messages between objects and roles within the collaboration Model alternative scenarios within use cases or operations that involve the collaboration of dierent objects and interactions Support the identication of objects (hence classes) that participate in use cases
Massimo Felici Communication Diagrams c 20042011
Communication Diagrams
The communication is implicit in a Sequence Diagram, rather than explicitly represented as in a Communication Diagram There is some redundancy between Communication and Sequence Diagrams They dierently show how elements interact over time They document in detail how classes realize user cases Communication Diagrams show relationship between objects Sequence Diagrams focus on the time in which events occur
Massimo Felici
Communication Diagrams
c 20042011
Example
Massimo Felici
Communication Diagrams
c 20042011
What is a Collaboration?
Communication Diagrams
A Collaboration is a collection of named objects and actors with links connecting them A Collaboration denes a set of participants and relationships that are meaningful for a given set of purposes A Collaboration between objects working together provides emergent desirable functionalities in Object-Oriented systems Objects collaborate by communicating (passing messages) with one another in order to work together
Massimo Felici
Communication Diagrams
c 20042011
Collaborations
Actors Each Actor is named and has a role One actor will be the initiator of the use case Objects Each object in the collaboration is named and has its class specied Not all classes need to appear There may be more than one object of a class Links Links connect objects and actors and are instances of associations Each link corresponds to an association in the class diagram
Massimo Felici
Communication Diagrams
c 20042011
Interactions
Use Cases and Class Diagrams constrain interactions Associations and Links in a Collaboration Diagram show the paths along which messages can be sent from one instance to another A message is the specication of a stimulus A stimulus represents a specic instance of sending the message, with particular arguments
Massimo Felici
Communication Diagrams
c 20042011
Communication Diagrams
Specication level shows generic cases of collaborations (communications) Generic form captures a collaboration among class roles and association roles and their interactions Instance level shows a specic instance of an interaction taking place and involving specic object instances Instance form captures a scenario among objects conforming to class roles and links conforming to association roles
Massimo Felici
Communication Diagrams
c 20042011
A communication link is shown with a single line that connects two participants
Massimo Felici
Communication Diagrams
c 20042011
Simple Example
10
Communication Diagrams
Massimo Felici
Communication Diagrams
c 20042011
11
Messages
A message on a communication diagram is shown using an arrow from the message sender to the message receiver Message Signature: return-value, message-name, argument-list Each message in a collaboration diagram has a sequence number. The top-level message is numbered 1. Messages sent during the same call have the same decimal prex but suxes of 1, 2, etc. according to when they occur.
Massimo Felici
Communication Diagrams
c 20042011
12
Messages
Synchronous
Asynchronous
Creation
Reply
Massimo Felici
Communication Diagrams
c 20042011
13
Messages
Procedural or Synchronous: A message is sent by one object to another and the rst object waits until the resulting action has completed. Asynchronous: A message is sent by one object to another, but the rst object does not wait until the resulting action has completed. Flat: Each arrow shows a progression from one step to the next in a sequence. Normally the message is asynchronous. Return: the explicit return of control from the object to which the message was sent.
Massimo Felici
Communication Diagrams
c 20042011
14
Messages
Messages occurring at the same time: Adding a number-and-letter notation to indicate that a message happens at the same time as another message Invoking a message multiple times: Looping constraint, e.g., *[i=0..9] Sending a message based on a condition: A guardian condition is made up of a logical boolean statement, e.g., [condition=true] When a participant sends a message to itself
Massimo Felici
Communication Diagrams
c 20042011
15
Messages
The message is directed from sender to receiver The receiver must understand the message The association must be navigable in that direction Law of Demeter Dealing with a message m an Object O can send messages to: Itself Objects sent as argument in the message m Objects O creates in responding to m Objects that are directly accessible from O, using attribute values
Communication Diagrams c 20042011
Massimo Felici
Activations
16
Flow of Control
Procedural interactions At most one object is computing at any time Activation An object has a live activation from when it receives a message until it responds to the message Waiting for response Synchronous messages on sending a message to another object, an object will wait until it receives a response Activation task Activations are stacked and the top activation has control. When the top action responds the next to top regains control and so on...
Massimo Felici
Communication Diagrams
c 20042011
17
In Communication Diagrams the objects are labelled: New for objects created in the collaboration Destroyed for objects destroyed during the collaboration
Massimo Felici
Communication Diagrams
c 20042011
:DirectorOfStudies {new}
:DirectorOfStudies
3:destroy()
18
! ! ! ! !
Sequence Diagrams
! ! ! ! !
Massimo Felici
Communication Diagrams
c 20042011
19
Massimo Felici
Communication Diagrams
c 20042011
20
Readings
Required Readings UML course textbook, Chapter 10 on More on Interaction Diagrams Suggested Readings K.J. Lieberherr, I.M. Holland. Assuring good style for object-oriented programs. IEEE Software 6(5):38-48, 1989.
Massimo Felici
Communication Diagrams
c 20042011
21
Summary
Interaction Diagrams Sequence Diagrams Communication Diagrams Communication Diagrams Rationale Communication Diagrams Collaborations Interactions Messages Constructing Communication Diagrams
Massimo Felici Communication Diagrams c 20042011