Pattern types

Pattern authors must select one of three different Unified Modeling Language (UML) types to define the pattern body. The acceptable types are collaboration, class, and package. Most patterns are collaboration patterns because this type is the most flexible in pattern design and application.

Following the UML 2.0 rules, the pattern type determines the allowable target element types in pattern application. For example, you can successfully apply a package type of pattern to a UML package or to a UML model (a model is a type of package); packages can own packages. However, you cannot apply a pattern of type package to a UML class; a class cannot own a package.

The following list shows the allowable target types based on the pattern type:

During design, the pattern author can limit the allowable target types by clearing the options in the New Pattern wizard. For example, the default targets for a collaboration type pattern can be limited to classes.

In addition to following UML rules, one of two default behaviors occurs in pattern application. A pattern instance is added to the target element as a child node or the target element is modified to become the pattern instance. The behavior depends on the pattern author's design and the UML 2.0 type of the target element.

The following table shows the default application behaviors based on the pattern type.

Default behaviors by pattern type
  Pattern type
  Package type Collaboration type Class type

Target element in UML 2.0 model

Package target Adds a package type pattern instance to the target. Adds a collaboration type pattern instance to the target. Adds a class type pattern instance to the target.
Collaboration target Not allowed. Changes the target collaboration into a pattern instance of type collaboration; adds pattern parameters to the instance. Not allowed.
Class target Not allowed. Adds a collaboration type pattern instance to the target. Modifies the target class by adding a pattern stereotype. Does not add any of the pattern's parameters.
Related concepts
Pattern framework
Pattern definitions
Pattern project contents
Pattern instantiations
Pattern expansion
Related tasks
Regenerating source code
Regenerating pattern definitions
Feedback
(C) Copyright IBM Corporation 2004, 2005. All Rights Reserved.