UML pattern frameworks

You can select the generalized or the specialized UML patterns framework as the root framework for your pattern library. The generalized UML pattern framework is an object-oriented framework that provides support for the base classes that the standard pattern implementation model extends. The specialized patterns framework provides additional functionality such as role-marking and traceability features for pattern participants.

Generalized UML patterns framework

The generalized patterns framework is the default framework that defines the common default behavior across all pattern implementations. This framework implements the necessary service protocols that activate the pattern in the product. The core pattern plug-in components contain the default framework that provides the base classes that pattern implementations specialize.

The pattern structure is defined in terms of both UML and Reusable Asset Specification (RAS) asset metamodels. A UML representation of the pattern persists in the pattern plug-in project. The model-operative patterns operate on UML models and their elements. The pattern service discovers the available pattern plug-ins from several sources, including installed plug-ins and local or remote RAS repositories. The pattern service also identifies pattern definitions, creates pattern instances, and directly supports the client UI components. Both the pattern service and the pattern framework are Eclipse plug-ins.

The pattern programming model simplifies pattern authoring because the author must supply code only for the pattern behavior. The locations where you add the expansion behavior are known as hot spot methods, and are indicated by empty expansion methods. For help with pattern code design, see the package named com.ibm.xtools.patterns.framework that contains the classes AbstractPatternParameter and PatternParameterValue.

The AbstractPatternParameter class is the common implementation for a pattern parameter, and other concrete pattern parameter subclasses indirectly use and further specialize it. The abstract pattern parameter is the primary abstraction at run time that enables an extension to occur through parameters, parameter dependencies, and delegates. This class contains hot spot methods that you can override. Most pattern implementations implement some or most of these hot spot methods by overriding their methods. The most frequently implemented hot spot methods are the expand and isValid methods, which you can use to implement the pattern application behavior, and to resolve and determine the validity of the specified parameter values.

The PatternParameterValue class encapsulates all the information that is needed to qualify a value to the proper pattern parameter and pattern instance. This class contains nested subclasses that provides state-specific behavior that corresponds to the state of the pattern parameter value. For example, when an expand method is called, the specific behavior that the pattern author provides is added to the expand method and the signature references the direct type of the pattern parameter value.

You can also add a dependency relationship by using the New Pattern wizard when you add a new pattern, or by using the Properties page in the Pattern Authoring view. When you add a pattern, the code for the dependency-specific hot spot methods is added to the pattern implementation code. The three types of update methods are generated only for the client parameter. Update methods are invoked when the following activities occur:
  • A supplier argument is added
  • A supplier argument is removed
  • A supplier argument does not change when the pattern is reapplied

You can use update methods to suppress the total or partial expansion of the client parameter until the required values are specified in the supplier parameters. The AbstractPatternDependency class (com.ibm.xtools.patterns.framework) contains the update methods. This class represents a dependency between two pattern parameters; the dependent pattern parameter depends on the dependency parameter. The class observes the dependency parameter and notifies the dependent parameter under the various state-triggered update methods.

You typically associate a pattern parameter dependency with a pattern parameter by instantiating a dependency in the constructor of a pattern parameter. Dependencies are stored and managed in the abstract pattern parameter class. This class must have a subclass of a concrete dependency implementation that can override the defined hot spot methods to change the dependency runtime behavior. By default, you can find the hot spot methods by examining which methods are not marked final. In this class, the hot spots are primarily the variants of the overloaded update method. For a listening of the hot spot methods and their application, see the Rational® Patterns Developer Guide.

Specialized UML patterns framework

The specialized patterns framework extends the generalized framework and provides role-related enhancements to patterns. The pattern libraries that use the specialized framework depend on both the specialized and the generalized framework. The specialized patterns framework supports the traceability of pattern participant roles in the design pattern library. Pattern authors should choose the specialized patterns framework as the patterns framework root for their pattern library to use the traceability and role-marking features for pattern participants.

The design patterns that the product includes use the specialized pattern framework to manage read-only pattern argument model elements during pattern application. The pattern instances own the trace relationships to involved elements. You can use model elements from read-only models as parameters to some patterns. The product support for the authoring and application of UML profiles means that you can use profile stereotypes and associated profile enumerations as pattern parameters

The specialized patterns framework manages read-only models by ensuring that only elements in the specific pattern instance model receives writes. Also, traceability support and keyword functionality for roles is built in to the specialized framework, and is no longer implemented separately in the GoF code.

For patterns that are rooted in the specialized patterns framework, you can see the effects of the framework after a pattern author associates a model element with a certain role. For example, if a pattern author instantiates a pattern from a pattern library that is rooted in the specialized pattern framework, after instantiation, the pattern author can interact with the pattern occurrence. The pattern author can interact by dragging a model element to an arbitrary pattern role compartment. The pattern occurrence is also known as the pattern instance. The pattern role compartment is also known as the pattern parameter.

Because the pattern is part of a pattern library that is rooted in the particular specialized patterns framework, two additional effects occur:

  • The pattern participant is now marked with a keyword that derives its name from the targeted pattern role.
  • An abstraction relationship now exists from the pattern occurrence, also known as the pattern instance to the pattern participant, which is the model element that is bound to the targeted role. This relationship enables the author to work more easily with the participants of the pattern occurrence as a group.

Pattern participant role marking enables a pattern user, also known as a pattern applier, to know which roles a given model element has assumes. For example, assume that a simple pattern has three roles, also known as pattern parameters: Past, Present, and Future. After a pattern participant, also known as a pattern argument, binds to a given role, a lightweight stereotype which is known as a keyword, is applied to that participating model element. If a model element named Cornelius is bound to the role Future, the model element Cornelius now holds a keyword of Future and is visualized as *!ENTITY!**!ENTITY!*Future Cornelius instead of the former Cornelius.

Another feature of the specialized pattern framework is the traceability of pattern participant roles. For example, if a straightforward pattern with one role, Singularity, has a pattern participant bind to this role, an abstraction relationship is created from the pattern-occurrence model element to the participant model element. In this example, the pattern-participant model element named Slim is bound to the pattern role named Singularity, which creates an abstraction relationship between the model element that is the pattern occurrence and Slim. In this case, the pattern occurrence is a UML collaboration named Singularity Pattern Instance 1. The pattern occurrence owns the abstraction relationship.

For help with pattern code design, see the package com.ibm.xtools.patterns.framework.specialized that contains the class AbstractPatternLibrary which offers more features than the standard generalized patterns framework.

Feedback