UML Collaboration Diagrams
UML Collaboration Diagrams 4 Collaboration Diagram Semantics
• Collaboration Diagram Notation
• Collaboration Diagram Examples
• Collaboration Diagram Issues
Michael Jones UML Collaboration Diagrams 2
1
Collaboration Diagram Semantics
• • Member of the Behavioural Group of diagrams Behavioural description includes
– as well as Sequence, Statechart, and Activity diagrams – static - structural description on the participants – dynamic - description on the execution of the actions – set of participants and interactions which are meaningful in a c ontext – models the exchange of messages between objects to achieve something – operation or use case – class
• • •
Collaboration Purpose
Can be attached to:
•
Parameterised collaboration
– can be reused – can assist in defining the structural aspects of a design pattern
Michael Jones
UML Collaboration Diagrams
3
UML Collaboration Diagrams • Collaboration Diagram Semantics
4 Collaboration Diagram Notation
• Collaboration Diagram Examples
• Collaboration Diagram Issues
Michael Jones UML Collaboration Diagrams 4
2
Collaboration Diagram Notation
• • • • Represents a Collaboration and Interaction Collaboration Interaction Objects
– set of objects and their interactions in a specific context – set of messages exchanged in a collaboration to produce a desired result – rectangles containing the object signature – object signature: object name : object Class • object name (optional) - starts with lowercase letter • class name (mandatory) - starts with uppercase letter – objects connected by lines – user (stick man) can appear – are labelled like C and Java function calls • followed by round brackets, and can have parameters and return values – are followed by an arrow to show direction – internal messages are numbered, starting from 1
Michael Jones UML Collaboration Diagrams 5
•
Messages
UML Collaboration Diagrams • Collaboration Diagram Semantics
• Collaboration Diagram Notation
4 Collaboration Diagram Examples
• Collaboration Diagram Issues
Michael Jones UML Collaboration Diagrams 6
3
Collaboration Diagram Example
• Scenario: refreshing the icons in a folder window
refresh()
:Renderer
window:Window
1: refreshIcons(window) 1.1: create(icon)
1.1.1: add(self)
:IconManager
:BitmapGenerator
Michael Jones
UML Collaboration Diagrams
7
UML Collaboration Diagrams • Collaboration Diagram Semantics
• Collaboration Diagram Notation
• Collaboration Diagram Examples
4 Collaboration Diagram Issues
Michael Jones UML Collaboration Diagrams 8
4
Collaboration Diagram Issues
• Message Signature
– guard • condition applied to the message • in square brackets at the start of the signature – – – – sequence number • numbers separated by dots, ending in a colon return value • name followed by := operation name argument list • names separated by commas, within round brackets
• •
Types of message flows
– synchronous, asynchronous, simple
Multiplicity of objects
– how can messages sent to a multiplicity (e.g., an array) of objects be represented?
UML Collaboration Diagrams 9
Michael Jones
Types of Message Flows
• Simple
– indicates flow of control - sender waits until receiver processes message – default – shown by an 'empty' arrow
•
Synchronous
– indicates nested flow of control – used to ensure that state cannot be compromised by external factors • e.g., not interrupted by the operating system – shown by a 'filled' arrow
•
Asynchronous
– a signal from one object to another – shown as half an empty arrow
Michael Jones
UML Collaboration Diagrams
10
5
Multiplicity in Collaboration Diagrams
• A server object needs to send a message to each user logged in, and another message to the audit object (which keeps a track of messages sent)
:Admin
1. sendWarning(text:String)
*
:User
2. addMessage(text:String)
:Audit
Michael Jones
UML Collaboration Diagrams
11
Summary
• Collaboration Diagram Semantics
– objects and messages – static representation of messages which could be sent – sequence of messages indicated
•
Collaboration Diagram Notation
– rectangles for objects • object signature: name : Class – messages with arrows • message signature • [ guard] sequence number : result := messageName(int)
•
Collaboration Diagram Issues
– multiplicity – when to use
Michael Jones
UML Collaboration Diagrams
12
6