Collaborations

In UML diagrams, a collaboration is a type of structured classifier in which roles and attributes co-operate to define the internal structure of a classifier. You use a collaboration when you want to define only the roles and connections that are required to accomplish a specific goal of the collaboration. For example, the goal of a collaboration can be to define the roles or the components of a classifier. By isolating the primary roles, a collaboration simplifies the structure and clarifies behavior in a model.

Because you do not show the specific classes or identities of the participating instances, but only the roles and connectors, you can reuse a collaboration to diagram architectural patterns of collaborating objects and to model their common behavior, similar to a template. When you want to show a specific occurrence of a pattern, you use a collaboration use.

A collaboration can include classifiers from different parts of the system being modeled, and a single classifier can play different roles and participate in multiple collaborations. This means that a role in a collaboration references or types a classifier, but the collaboration does not physically own or contain the referenced classifier.

As the following figure illustrates, a collaboration is displayed as a dashed ellipse with two compartments.

A collaboration between a Car frame and two connected roles that represent the parts Door and Frame.

The top compartment specifies the unique name of the collaboration. Typically, the name identifies the pattern or mechanism that the collaboration provides. In the above example, the collaboration defines the components of a car. The name of the collaboration is Car. The structure compartment shows the internal structure of the collaboration by using a set of roles. In this example, the Door and the Frame roles collaborate to define the collaboration Car. The roles are depicted as rectangles that contain the name of the role, a colon, and, if specified, the name of the referenced classifier. A solid line connects the Door and the Frame roles in the collaboration.


Feedback