Applying Patterns

After creating the roles associated with the user-defined pattern, you are now ready to apply the pattern. Applying a pattern involves either selecting existing elements in your project to apply the properties and relationships to, or creating new elements with the properties and relationships specified in the pattern.

Patterns can be applied from the Projects window or the UML Design Center window. A pattern in the Projects window can be applied only to that project. A pattern in the UML Design Center can be applied to any project. See Using the Design Center for more information.

To apply a pattern:

  1. Select the pattern.
    You can select the pattern from the Projects window, the UML Design Center window, or a diagram in which the pattern exists.
  2. Right-click the pattern and choose Apply Design Pattern.
    The Welcome pane of the Design Pattern Apply Wizard opens.
  3. Click Next to continue.
    The Pattern Selection panel opens with the project containing the pattern and the pattern itself selected.
  4. Click Next to continue.
    The Target Scope panel opens with the target project.
  5. (Optional) Select a package from the Namespace list.
    If you are creating new elements in your project, the elements are created in the selected package.
  6. Click Next to continue.
    The Choosing Participants panel opens. This is the panel where you specify the elements that are to receive the properties and relationships of the roles in the pattern.
  7. To add elements, do the following:
    1. On the Choosing Participants panel, right-click the row containing the participant with multiplicity and choose Create.
      An additional row is added to the grid for the extra participant.
    2. Continue adding participants as allowed.
    3. Select the Participant row and type a name for both of the elements.
  8. To create new elements for the roles, select a row in the Participant column and type a name for each of the new elements. To apply the pattern to existing elements, select the elements from the drop-down lists in the Participant column.
  9. When you have selected the participants, click Next to continue.
  10. To create a class diagram containing the elements to which the pattern has been applied, do the following:
    1. Select the Create class diagram checkbox.
    2. Specify a name for the diagram and click Next.
  11. Review your selections on the summary panel and click Finish to apply the pattern.
    After the pattern has been applied, you may be prompted to generate code for the elements. If you choose to generate code for the participants, a progress bar is displayed. In this case, click Done when code generation is complete.
    If you choose to create a class diagram, the diagram is displayed in the Diagram editor.
  12. Save the diagram and the project.

Legal Notices