Adding patterns and parameters to libraries

The pattern author can add one or more patterns to the pattern library. Each pattern is independent in function and application. However, a pattern can only be distributed with its library in a pattern plug-in.

Before you can perform these steps, you must create a pattern library.

The New Pattern wizard enables you to define the properties for the pattern and add all of its template parameters. After the pattern is added to the library, you can modify the pattern's properties and add, redefine, or remove its parameters. Many of the steps are optional. You can create a simple pattern by accepting all of the defaults.

To add a pattern and its parameters to the pattern library:

  1. In the Pattern Authoring view, right-click the library node and click New Pattern. The General page of theNew Pattern wizard is displayed.
  2. Define the basic pattern properties by completing the following steps:
    1. Type a name for the pattern in the Pattern Name field. This is the name that will be listed in the Pattern Explorer view to identify the pattern.
    2. Accept the generated class and package names as generated from the pattern name or modify them in the Class Name and the Package fields.
    3. From the Pattern Type list, select elect the type of pattern (Class, Collaboration, or Package) you are creating.
    4. Click the Add button next to the Groups field to open the Add Group window and add group names to the pattern. Patterns must be assigned to at least one group and can be assigned to multiple groups. All patterns are listed in groups in the Pattern Explorer view. The default group, Miscellaneous Patterns, can be deleted.
    5. In the Version field, modify the version number. The number must be in an nn nn nn format where n is a number.
    6. Click the Detail tab to open the Detail page of the New Pattern wizard.
    7. Type your name in the Author field.
    8. Type a brief pattern synopsis in the Short Description field. This short description is displayed on the Short Description page of the Pattern Explorer view.
    9. Click the Add button next to the Keywords field and add keywords for the pattern. Add keywords that a pattern applier would use to find a match to your specific pattern. The metafiles in the pattern are also searched for matches so you do not need to duplicate any of the contents of such properties as descriptions or names.
  3. Add parameters by doing the following steps:
    1. Click the General tab to return to the General page of the New Pattern wizard.
    2. Click the Add button next to the Parameters field to display the General page of the New Pattern Parameter wizard. You can always add or modify parameters after you finish using the wizard.
    3. Type a name for the parameter in the Name field. The class name is automatically derived from the parameter name.
    4. Accept the class name as generated or modify it in the Class Name field.
    5. Type a short description of the parameter that can assist the pattern applier to specify arguments for the pattern. This description is displayed on the Short Description page of the Pattern Explorer view and as hover help when the pattern applier hovers over the template parameter in the diagram editor.
    6. In the Type field, accept the default UML 2.0 type of Class for the parameter's type or click Browse and select another UML 2.0 type.
    7. If the Allowable Subtypes field is enabled, accept the default, to have all subtypes available to the pattern applier as possible kinds of arguments, or click Browse, to select a limited set of subtypes.
    8. Accept or clear the Allow text entry of argument value check box that permits specifying or creating arguments by typing an argument name.
      Note: For parameters that you create with multiple subtype options, the subtype that is created from the pattern applier's text entry is controlled by the code you supply in the parameter's update method. If you do not supply this code, a default subtype from your allowable subtypes list is selected.
    9. If you are adding the pattern's first parameter or do not want to add a parameter dependency, go to step 3.k. To add a dependency, click the Parameter Dependency tab.
    10. On the Parameter Dependency page, in the Existing Parameters field, click one or more parameter names and then click the right-arrow button to position the parameter names in the Client Parameters field or the Supplier Parameters field. When you assign another parameter as a client or supplier parameter, it dynamically adds the reciprocal assignment to the parameter you are adding. Thus, moving an existing parameter into the Supplier Parameters field assigns the role of client to the parameter you are adding.
    11. Click OK to return to the New Pattern wizard.
    12. To add additional parameters, repeat steps 3.b through 3.k.
    13. Click OK to close the New Pattern wizard and complete the addition of the pattern.
The new pattern is added as a node to the pattern library in the Pattern Authoring view and the supporting RAS metafile for the pattern asset and the Java™ classes for both the pattern and each parameter are created.
Related concepts
IBM Rational design patterns
Pattern code and support files
Feedback
(C) Copyright IBM Corporation 2004, 2005. All Rights Reserved.