Patterns to apply details |
This sample is a set of 8 patterns. Many of these patterns are similar in name and function to industry accepted patterns.* Some of these patterns are used by other patterns of higher granularity and are known as micropatterns. Implementation pattern(Two parameters, one parameter dependency, a micropattern) The implementation pattern is a primitive pattern that is self-contained and leverages no other patterns in its implementation. It is a very simple pattern that ensures a UML implementation relationship is present from an implementation argument to an interface argument. Interface pattern(Two parameters, one parameter dependency, reuses one pattern) The interface pattern, a pattern that is reused by a few other sample patterns, also reuses a pattern in its implementation. The implementation pattern is a very primitive pattern (also referred to as a micropattern) and is used by the interface pattern to ensure the implementation argument implements the interface arguments. The interface pattern has two parameters, one to represent the interface and one to represent the implementation. It includes an example of basic delegate mapping using pattern definition usages and pattern dependency delegates. This is a very basic yet functional pattern that is also mentioned in other parts of the patterns documentation. This pattern also shows the combination of using both pattern delegates and custom code to implement a pattern's dependency update methods. The implementation pattern is reused in order to ensure the implementation relationship, and then custom update method code is used to ensure the implementation implements all defined operations on the interface arguments. Keyword list pattern(Two parameters, one parameter dependency, a micropattern) The keyword list pattern is a primitive pattern that is self-contained and does not leverage other patterns in its implementation. It also demonstrates the use of a UML literal string as a parameter type and the use of an abstract UML metatype as a parameter type. This pattern also includes functionality to correctly ensure the pattern semantics as arguments are unbound and pattern instances are unapplied. The keyword list pattern can be instantiated from the Pattern Explorer view in its own right, but it is better suited to be reused by other patterns through the pattern delegate mechanism. Directed association pattern(Six parameters, five parameter dependencies, a micropattern) The directed association pattern is another self-contained primitive pattern, a micropattern that is used by other patterns of higher granularity. The directed association pattern has two primary parameters that set the context for a directed association. It has five other peripheral parameters that help shape the association by configuring the association type, the role names, and the multiplicities. This pattern is reused by the sample delegation pattern and is an example of a pattern that includes many less common parameter types. Literal strings, integers, and pattern enumerations are used in the definition of this pattern. The pattern code found in this sample to handle these literals and enumerations is invaluable to pattern authors when learning to author patterns that have similar parameter types. Delegation pattern(Two parameters, one parameter dependency, reuses three patterns) The delegation pattern has two parameters: one parameter that represents the delegator and one parameter that represents the delegate in the delegation pattern. The delegator delegates operations defined on the delegate interface and implemented by the delegator to an instance of the delegate type. This pattern demonstrates the use of delegate mapping filters to customize the name of the keywords bound to the keyword list pattern reuse instances. This customization of name is not required in order to provide a useful implementation of the delegation pattern, but it has been added to this sample to demonstrate the use of delegate mapping filters. Strategy pattern(Three parameters, two parameter dependencies, reuses two patterns) The strategy pattern is based on the commonly known strategy pattern. It reuses the keyword list and interface sample patterns and contains an example of parameter delegate mapping. It has three parameters, one to represent the strategy interface, one to represent the concrete strategy, and one to represent the context of the strategy itself. To demonstrate the reuse of the keyword list pattern, the pattern ensures that the <<Strategy>> keyword is present on the argument of the strategy interface parameter. The interface pattern is reused to ensure that the strategy interface is implemented by the bound arguments of the concrete strategy parameter. Singleton pattern(Zero parameters) The singleton pattern is based on the commonly known singleton pattern. It is an example of a parameterless pattern. It has an implicit parameter, which can be thought of as the pattern instance itself. This pattern represents its pattern instances as classes instead of the typical more usual representation as collaborations. A functional use of this pattern is to drag it from the Pattern Explorer view to a class that you need to ensure is a singleton. Dragging this pattern on to the diagram surface (into a package) results in a new singleton instance and, therefore, creation of a new class to represent this instance. Abstract factory pattern(Five parameters, five parameter dependencies, reuses one pattern) The abstract factory pattern is based on the commonly known abstract factory pattern. It reuses the interface pattern and, therefore, demonstrates dependency delegates in the course of delegating behavior to the interface pattern. It is a degenerate implementation of the abstract factory pattern in that all concrete products implement all abstract product interfaces that are bound. It exemplifies the use of parameter dependencies to keep maintain a pattern's semantics ensured as additional arguments are bound to the pattern. Just as the singleton pattern employs something other than collaborations to represent pattern instances, this pattern uses packages. Instances of this pattern are packages. * Design Patterns: Elements of Reusable Object-Oriented Software, Gamma, Helm, Johnson and Vlissides (Addison-Wesley, 1995) copyright (c) 1995 by Addison-Wesley Publishing Company, Inc. All rights reserved. |