Adding parameters to patterns

A pattern usually has at least one parameter although this is not a requirement. Parameters define the targeted argument's UML 2.0 type and the acceptable multiplicity values. Each parameter is represented by a Java™ class and contains the code instructions to perform the work accomplished by pattern expansion.

You must create a pattern before you can perform these steps.

You can specify dependencies between parameters. 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 Parameter field assigns the role of client to the parameter you are adding.

To add a parameter to a pattern:

  1. In the Pattern Authoring view, right-click the pattern and click New Parameter. The New Pattern Parameter wizard opens.
  2. Type a name for the parameter in the Name field. The class name is automatically derived from the parameter name.
  3. Accept the class name as generated, or modify it in the Class Name field.
  4. Type a short description of the parameter that can assist the pattern applier to specify arguments for the pattern. The short 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 on the diagram view.
  5. In the Type field, accept the UML 2.0 type of Class for the parameter's type or click Browse and select another UML 2.0 type.
  6. If the Allowable Subtypes field is enabled, do one of the following:
    • Go on to the next step. All subtypes will be available to the pattern applier as possible kinds of arguments.
    • Click Browse and select the subtypes that you allow the pattern applier to choose as arguments for this parameter. For example, for a classifier type, you can choose the subtypes of interface, class, activity, and collaboration.
  7. Accept or clear the Allow text entry of argument value check box that permits the applier to specify an existing argument or create new argument elements 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.
  8. To add a parameter dependency, complete the following steps:
    1. Click the Parameter Dependency tab to open the Parameter Dependency page.
    2. In the Existing Parameters field, click one or more parameter names.
    3. Click a right-arrow button to move the parameter name into the Client Parameter field or the Supplier Parameter field.
  9. Click the General tab to return to the parameter definition or OK to close the wizard.
The parameter is added to the pattern. As you develop the pattern, you can modify the parameter properties by using the Properties view.
Related concepts
IBM Rational design patterns
Pattern code and support files
Related tasks
Creating pattern projects and libraries
Assigning patterns to groups
Adding dependencies to parameters
Setting pattern property values
Feedback
(C) Copyright IBM Corporation 2004, 2005. All Rights Reserved.