Pattern syntax

 

General structure and interpretation rules

An ACT pattern definition consists of a <pattern> XML element, which in turn contains a <body> element, inside which the <event> elements are defined.

 

Each event element contains a <j-code> section with the J language code to be executed in the case of the corresponding event (for example, to create a constructor operation when a class is created, to rename it when the class is renamed, …).

 

 

Example

The following is a short example of a pattern.

<pattern id="CxxSimpleProperty" kind="access-pattern">

   <body>

        <event id="create">

              <j-code>

                   //J code

              </j-code>

        </event>

        <event id="delete">

              <j-code>

                   //J code

              </j-code>

        </event>

   </body>

</pattern>

 

 

<pattern> element

The <pattern> element contains the following attributes:

·         id: This contains a string identifier of the pattern, which should be unique within a library (but can be overridden in a different library), and which is used to access the pattern during runtime.

·         kind: This is the classifier attribute, used to further organize patterns in the library, for example, patterns driving the decoration of a private member with accessor methods can be marked as "access-pattern", ….

 

 

<event> element

The <event> element within a <pattern> element defines the reaction to certain "events", in other words, the certain kind of change that takes place in a UML model, which is relevant to the semantics of the pattern.

 

For example, an access pattern proposing a pair of access methods (getter and setter) for each atomic attribute should add the corresponding UML operations in the event of the creation of a new attribute, rename them if the name of the attribute changes, and delete the operations if the attribute is deleted.

 

The <event> element has the following attributes:

·         id: This is a string identifier of the system event.  Available identifiers are "create", "rename" and "delete".