In the sequence or collaboration diagram you can create associations between objects (located on an interaction diagram) and classifiers (located on some class diagram). Instantiated classes for an object can be selected from the model, or the classes can be created and added to the model.
Note that an object can instantiate classifiers that belong to the various source-code projects within a single project group, when such projects are referenced from the project in question.
The range of available classifiers depends on the project type.
- Design projects: classes, interfaces
- C# implementation projects: classes, interfaces, structures
To associate an object with an existing classifier:
- Select an object.
- On the context menu of the object, select Choose class.
- The submenu displays the list of available classifiers. If you cannot find the required classifier in the list, click More to reveal the model tree view.
- In the Choose Type to Instantiate dialog box that opens, select a classifier from the model and click OK.
Tip: Alternatively, use the Object Inspector
. Click the
Instantiates field and select the classifier from the model. Result: The object displays the fully qualified path to the instantiated classifier.
Tip: To associate an object with a classifier from a different project, add this project as a referenced one.
To create a new classifier for an existing object:
- Select an object.
- On the context menu, choose Add.
- From the submenu, choose the desired classifier type.
Result: A new classifier is added to the model. A shortcut for the new classifier appears on the interaction diagram in question, connected with the object by a dependency link.
To unlink an object:
- Select an object.
- On the context menu of the object choose Unlink class.
Result: The association is removed, but the classifier is preserved in the model.
To navigate between classifiers and objects:
- Select the object on the diagram.
- Right-click and choose Synchronize Model View on the context menu to move focus to this classifier in the Model View, or choose Go to Class Definition to open this classifier in the source code (for implementation projects).
To create a shortcut to a classifier on an interaction diagram:
- On the diagram, select an object that instantiates a classifier.
- Right-click and choose Import class on the context menu.
Result: A shortcut to the instantiated classifier is added to the diagram.