Association
The plot is the same as the Sequence Graph in many aspects. Both are used to record the interaction of objects. However, the sequence chart is based on time, while the collaboration chart displays objects and their associations without emphasizing time. Collaborate graph display to eliminate Interaction
Information sequence. The difference between the two lies in this. Therefore, the relevant content of the sequence diagram is also applicable to the collaboration diagram. These two types of graphs are only two different ways to express things. The collaboration diagram is used to view the dynamic content of the system. Because the collaboration Diagram
Messages do not emphasize the time, So numbers are required to understand the order in which they appear.
A collaboration diagram contains three basic elements:
● Object
● Link (between objects)
● Message
4.3.1 object
The object contains the name, status, and behavior. Each object in the figure indicates an instance of the class, which is why the object classifier needs to point to the class. The instance of the class of the VEA object must be notified. When building a collaboration diagram, right-clickYesInsert the collaboration diagram package, and select new | collaboration digoal from the pop-up menu. Two shapes indicate objects: classifier role and multi-object. In Figure 4-28, you can see the classifier role shapes object1 and multi-object shapes object2.
Figure 4-28 the classifier role and multi-object shapes in the Collaboration Diagram
The classifier role and multi-object shapes represent objects. The difference is that the classifier role shape represents a single object, while the multi-object shape represents a group of objects, these objects are instances of the same class. The classifier-to-class connection and attribute settings are the same as the sequence chart described in the previous section.
4.3.2 Link
The link is in the association role shape, indicating that the object is dependent on each other. The relationship often indicates that the object swaps messages.
To add a link, drag and drop the association role shape to the graph, and link the two connection points to each point of the two classifier role shapes. If the association role and classifier role are not associated with the existing association between the two basic classes, an error occurs. The reason is that the link needs to be directed to the actual Association (classifier ).
In Exercise 4-15, a collaboration diagram is built and objects and links are added.
Exercise 4-15
(1) create a UML Model in VEA.
(2) create a collaboration chart in the top package.
(3) create a static structure chart in the top package.
(4) drag the two class shapes to the static structure. By default, they are named class1 and class2, which meets the needs of this exercise.
(5) drag the binary Association shape from the UML static structure tab of model explorer to the static structure diagram to connect the two classes constructed in the previous step. Do not display the associated terminal name or number (right-click and select shape display options. Unselect first, second, and end, as shown in 4-29.
Figure 4-29 contains the associated static structure
(6) place the two classifier role on the collaboration diagram. By default, they are named object1 and object2, which meets the needs of this exercise. Set the object1 and object2 classifiers to class1 and class2 respectively.
(7) drag the association role from the collaboration tab of model explorer to the collaboration diagram to connect the two objects created in the previous step.
(8) set the basic association of the Association role to the binary Association (association1) constructed in step 1 ). Double-click Association role to open the UML Association role Properties dialog box, as shown in 4-30. In the base Association (Association list), select association1.
In Figure 4-30, you can see the attributes of the Association role shape in the Collaboration diagram. Note that the basic association is set to the current associated association1 (constructed between classes in the class graph of Exercise 4-15 ).
Figure 4-30 UML Association role Properties dialog box
Figure 4-31 shows the no-error collaboration diagram because the basic association has been set to the current Association of the static structure diagram. If no basic association is set for the association role, a red flag is displayed and an error is displayed in the output window.
Figure 4-31 includes the associated collaboration Diagram
4.3.3 message
Messages flow between objects, causing actions. As described above, links (associations) in a collaboration diagram can contain multiple messages. Double-click the association role shape (see Figure 4-31). In the UML Association role Properties dialog box (4-30), select the messages category to build the message, as shown in Figure 4-32.
Figure 4-32 build a message for the Collaboration Diagram
Note the sequence representation (seq. expr. Column) settings in Figure 4-32. When viewing the final collaboration diagram, it is necessary to know which messages occur first, as shown in Figure 4-33.
Figure 4-33 collaboration diagram containing messages
4.3.4 collaboration diagram Summary
The collaboration diagram is similar to the sequence diagram. The difference is that the sequence diagram is based on time, but the collaboration diagram does not emphasize time. A collaboration diagram is built when you record the tasks involved in the process. Compared with the sequence diagram, the collaboration diagram is more object-oriented because it emphasizes messages and objects. In the sequence diagram, because the time-based process is recorded, therefore, the process path is emphasized.