Rational Programming Patterns

Micropattern basic declaration principle

You insert a micropattern in the source code.

Micropatterns are independent of any language. You must conform to the declaration syntax.
Figure 1. Micropattern syntax
<MP-sequence><Micropattern ID> [<standard parameter> ]*
<header-delimiter-sequence><configuration area>
where:
  • <Micropattern ID> : [a-z,A-Z,[0-9]]*
  • <configuration area> : [<any character>]*
  • [<standard parameter> ] : <parameter-name> = ["] <value> ["]
Note: The general format of <MP-sequence> and <header-delimiter-sequence> depends on the underlying source code technology.

If you use a multi-line configuration area or multiple standard parameters, constraints might apply to each line format, depending on the underlying source code technology.

The following example shows the declaration of a micropattern which inverts two values.
Figure 2. Sample micropattern declaration
....|....1....|....2....|....3....|....4....|....5....|....6.
      *!INVERT / A B
            MOVE A TO TMP.
            MOVE B TO A.
            MOVE TMP TO B.

Upon generation, the micropattern engine is invoked to start the micropattern expansion process that will finally call the micro-generators. These micro-generators are instances of com.ibm.pdp.engine.IMicroPatternHandler.

The micropattern handler can then generate or generate again all or parts of its local generation area. It uses its given parameters, the pattern rules, and the underlying model as input. It can also use its local generation area as an input, thus analyzing this piece of source code to define new inputs.


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)