Adding dependencies to pattern parameters

Dependency relationships are specified between two or more parameters in the same pattern by using the Pattern Authoring view. Parameter dependencies control pattern expansion when the pattern is applied.

About this task

Pattern parameter dependencies are created between only two parameters. The Pattern Authoring view allows the entry of multiple supplier or client parameters per parameter, but this in turn generates multiple parameter dependencies for each pair of the indicated parameters. For example, if the parameter being edited is named "A", and "X" and "Y" are the supplier parameters then two parameter dependencies are attached to the parameter "A". Each parameter dependency's purpose is to receive notice when the supplier parameter of interest is modified. One parameter dependency located in "A" is updated when "X" changes, and the other one that is also located in "A", is updated when "Y" changes.

When parameter dependencies are added, the framework inserts update methods known as hot spots into the class for the designated client parameter. The pattern author adds Java code to the update method to provide the behaviors for partial or delayed expansion based on the needs of the design.

A pattern author defines a parameter dependency when the state change of a given parameter's arguments is of interest to another parameter's arguments. For example, when one parameter gets a new argument bound, another parameter argument might need to update its state to take this new binding into account.

You can add parameter dependencies when you do the following tasks:
  • Add a pattern and parameters by using the New Pattern wizard
  • Add parameters by using the New Pattern Parameter wizard
  • Add or edit parameter dependencies by using the Properties view

To add or edit parameter dependencies by using the Pattern Authoring view:

Procedure

  1. In the Pattern Authoring, view right-click the parameter and click Show Properties View The Properties view opens.
  2. If you are assigning other parameters to the pattern as clients to the current parameter, do the following steps:
    1. In the Properties view, click the Client Parameters row and click the browse button to open the Edit Client Parameter Dependency window.
    2. Under Existing Parameters, click one or more parameters and click the right-arrow button to move them into the Client Parameters field.
    3. Click OK
    A set of update methods is added to the parameters that you assigned as client parameters. You add code to the update methods to specify the expansion behavior when the pattern is applied. This parameter must supply values to the client parameters before their partial or complete expansion can occur.
  3. If you are assigning other parameters in the pattern as suppliers to the current parameter, do the following steps:
    1. In the Properties view, click the Supplier Parameters value box and click the browse button to open the Supplier Parameter Dependency window.
    2. Under Existing Parameters, click one or more parameters and click the right-arrow button to move the selected parameters into the Supplier Parameters field.
    3. Click OK
    A set of update methods is added to the parameter you were editing as it is now the client to your assigned supplier parameters. You add code to the update methods to specify the expansion behavior when the pattern is applied. This parameter requires values from the supplier parameters before partial or complete expansion can occur.

    The hot spot method invocations are optimized to be triggered when appropriate. For example, if there is no values for the client parameter, the supplier parameter will not call the client's update method. It can be assumed then, when the update method is called there is truly a value or values for both the client and supplier parameter set.


Feedback