690 likes | 1.12k Views
Collaboration diagrams. Purpose. A collaboration diagram is an alternate way to show a scenario. A collaboration diagram shows the objects and relationships involved in an interaction, and the sequence of messages exchanged among the objects during the interaction.
E N D
Purpose • A collaboration diagram is an alternate way to show a scenario. • A collaboration diagram shows the objects and relationships involved in an interaction, and the sequence of messages exchanged among the objects during the interaction.
Compared with a sequence diagram • A sequence diagram shows the objects and messages involved in an interaction. • They convey the same information as sequence diagrams, but they focus on object roles instead of the times that messages are sent • Sequence diagrams show the timing of the messages, but not the relationships among the objects. • A distinguishing feature of a Collaboration diagram is that it shows the objects and their association with other objects in the system apart from how they interact with each other. • The association between objects is not represented in a Sequence diagram. • Within sequence diagrams the order of interactions is established by vertical positioning whereas in collaboration diagrams the sequence is given by numbering the interactions.
Messages • Unlike sequence diagrams, collaboration diagrams do not have an explicit way to denote time and instead number messages in order of execution. • Sequence numbering can become nested using the Dewey decimal system. • For example, nested messages under the first message are labeled 1.1, 1.2, 1.3, and so on. • The a condition for a message is usually placed in square brackets immediately following the sequence number. • Use a * after the sequence number to indicate a loop.
Example • An Administrator using a Web Application to manage a user account. • Notice how you can follow the process from object to object, according to the outline below: • Find User 1.1 LookUpUser • Update User 2.1 ValidateUser 2.2 UpdateUser
As a decomposition diagram • The collaboration diagram can be a decomposition of a class, class diagram, or part of a class diagram; • it can be the decomposition of a use case, use case diagram, or • part of a use case diagram.
Collaboration diagrams • illustrate object interactions in a graph or network format.
How to Read the makePaymentCollaboration Diagram • The message makePayment is sent to an instance of Register. The sender is not identified. • The Register instance sends the makePayment message to a Sale instance. • The Sale instance creates an instance of a Payment.
Messages to “self” or “this” • A message can be sent from an object to itself. • This is illustrated by a link to itself, with messages flowing along the link.
Conditional Messages • A conditional message is shown by following a sequence number with a conditional clause in square brackets, similar to the iteration clause. • The message is sent only if the clause evaluates to true. Collaboration Diagram Sequence Diagram
Mutually Exclusive Conditional Paths Collaboration Diagram Sequence Diagram
Iteration or Looping • Iteration is indicated by following the sequence number with a star * • This expresses that the message is being sent repeatedly, in a loop, to the receiver. • It is also possible to include an iteration clause indicating the recurrence values. Collaboration Diagram Sequence Diagram