< Previous | Next >

Lesson 6: Bind existing elements as arguments

The lesson explores two different ways to specify existing UML model elements as pattern template arguments.

If you would like to view this lesson before you perform the steps, click:

Instead of creating a new UML element, you can select existing elements by typing the name of an existing element in the pattern instance on the diagram view. Or you can drag an existing element from the Project Explorer view or the diagram view onto the pattern instance.

To bind existing elements as arguments, you can use different methods such as specifying the name of an existing element as argument or dragging an existing element as an argument.

  1. To specify the name of an existing element as an argument:
    1. On the freeform or class diagram, hold the cursor over the Implementation parameter in the pattern instance. The action bar is displayed and a Class icon and a Text icon are available.
    2. Click the Text icon on in the action bar to type the name of an existing UML class element. A rectangular box appears next to the right-side of the template parameter.
    3. In the box, type AppFunction1 to specify the class from the sample model.
    4. Click outside the instance or press Enter to complete the name. A binding symbol replaces the blank box next to the template parameter followed by the name of the element.
    5. Observe the changes to the template binding in the Project Explorer view. The binding structure now shows the AppFunction1 class bound to the Implementation template parameter.

    The most important result is the two operations from the DoWork interface are now copied to the AppFunction1 class.

  2. To drag an existing element as an argument:
    1. On the freeform or class diagram, drag and drop the DoWork interface onto the left side of the Interface row in the pattern instance.

      Dragging an element onto a pattern instance will replace a previously bound element if the bound element was selected.

    2. In the Project Explorer view, observe the addition of the doNothing and doSomething operations to the AppFunction1 class resulting from the pattern binding.
    3. In the Project Explorer view, expand the instance's template binding structure to see the addition of the new interface element. The Interface template parameter is bound to a third interface element named DoWork.
You are ready to reapply the pattern and observe its effects on the model elements.
< Previous | Next >

Feedback