Exercise 4: Creating an instance of the pattern

This exercise explores a simple method of creating an instance of the Interface pattern on the class or freeform diagram.

When you apply a pattern, the first part of the sequence is creating the pattern instance. You can create more than one instance of a pattern and have them active at the same time. The easiest method to create an instance is to use the drag-and-drop method.

The pattern instance is a structure that is identifiable by the UML keyword Pattern Instance. Because the Interface pattern is based on a collaboration, it is contained by one of two unique user-selected shapes. Other types of patterns are package- or class-based, and these types of patterns mimic their respective elements on the diagram view. The pattern's template parameter definitions are abbreviated in the instantiation. The UML type and the multiplicity for each template parameter are also visible in the instance to aid the pattern applier in selecting or creating appropriate arguments to bind to the pattern.

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

Show me button Show Me

Before you begin, you must complete Exercise 3: Selecting the pattern.

Adding the pattern instance to the model

You can create more than one pattern instance for the same pattern in your workspace.
  1. In the Pattern Explorer view, drag the Interface pattern to the freeform or class diagram. The pattern is instantiated and the resulting pattern instance appears on the diagram.
  2. In the Model Explorer view, a pattern instance and a pattern definition now appear as part of the same sample UML model. No changes to the pattern definition are required to apply a pattern.
  3. Expand the pattern instance to see its contents. You will be able to see the changes that occur to the instance as you modify the pattern on the diagram in the next exercise.
  4. To view the properties for any elements in the Model Explorer view or the diagram view, right-click the element and click Properties.

You are now ready to learn how to supply arguments for the pattern's parameters. Go on to Exercise 5: Binding new arguments to pattern instances.

Terms of use | Feedback
(C) Copyright IBM Corporation 2004, 2005. All Rights Reserved.