Building a User-Defined Pattern

Once you have created a diagram, you are ready to build your pattern. This example covers building the Intercepting Filter pattern from the core J2EE patterns catalog.

First, be familiar with the types of modeling elements that are used when building patterns. The following table describes the usage for each of the element types:

Icon Name Description
Design Pattern icon Design Pattern Denotes a commonly-recurring structure of communicating components that solves a general design problem within a particular context.
Actor Role icon Actor Role Denotes an actor's role in the pattern. When applying the pattern to existing elements, only actors may be selected, or a new actor may be created to satisfy the role.
Class Role icon Class Role Denotes the role of a class in the pattern. When applying the pattern to existing elements, only classes may be selected, or a new class may be created to satisfy the role.
Classifier Role icon Classifier Role Denotes a classifier's role in the pattern. When applying the pattern to existing elements, only actors, classes, interfaces or use cases may be selected. If a new element is created, the type to be created is based on the Type to Create preference.
Interface Role icon Interface Role Denotes an interface's role in the pattern. When applying the pattern to existing elements, only interfaces may be selected, or a new interface may be created to satisfy the role.
Use Case Role icon Use Case Role Denotes a use case's role in the pattern. When applying the pattern to existing elements, only use cases may be selected, or a new use case may be created to satisfy the role.
Role Binding icon Role Binding Indicates that a role is participating in a pattern.

Using the diagram below as a reference, you can build the InterceptingFilter pattern. Use the steps following the diagram to create the design pattern.

Graphic displaying the Intercepting Filter pattern diagram

  1. In the Modeling Palette, click the Design Pattern icon Design Pattern icon and click in the diagram.
  2. Name the pattern InterceptingFilter.
  3. In the Modeling Palette, click the Class Role icon Class Role icon.
  4. Click once on the pattern, drag the cursor to an area adjacent to the pattern, and click again.
    The role is placed on the diagram and is automatically linked to the pattern.
  5. Name the role FilterTwo.
  6. Continue until you have added all seven class roles to the diagram and named them.
  7. In the Modeling Palette, click the Association icon Association icon, click the Target role, and click the FilterManager role.
    An association is created between the two roles.
  8. Continue adding associations until your diagram appears as in the example.

    Now the pattern is complete. In many patterns, you may want to add attributes or operations to your roles. You can add those just as you would add them to ordinary classes. See Working With Attributes and Working With Operations for more information.

  9. (Optional) You can document your pattern for future reference.
  10. Save your project by right-clicking the project node and choosing Save.

You have finished building your design pattern. Now you can apply the pattern to your project or promote it to the UML Design Center.


Legal Notices