Pree's Metapatterns
Pree's metapatterns are an expansion of the
Template Method
pattern
Encompasses several other patterns from
Gamma et al
Metapatterns are directed at framework class libraries:
Library "structures" the application or algorithm
Library is "in control"
Application developer overrides details of library's algothims
Metapatterns may be viewed (but aren't in the book) as the cross of 3 binary attributes:
unification vs connection
single reference vs multiple reference
non-recursive vs recursive
Pree's metapatterns may be viewed as the cross of 3 binary attributes
non-recursive
recursive
single
multiple
single
multiple
Unification
Unification
1:1 Recursive Unification
1:N Recursive Unification
Connection
1:1 Connection
1:N Connection
1:1 Recursive Connection
1:N Recursive Connection
All the single versions are represented by the patterns in
Gamma et al
(if you account for
1:1 Recursive Unification
being the degenerate case of
1:1 Recursive Connection
)
The multiple versions don't appear in
Gamma et al
except for
1:N Recursive Connection
, which is very similar to
Composite
Unification
Same as the
Template Method
pattern
Both the template and hook methods are in a single class
User subclasses to override the hook function
This is the least flexible approach as behavior is fixed at run time
Does
not
allow for behavior change at run time
1:1 Connection
Same as the
Strategy
pattern
The template class refers to one instance of the hook class
There is no inheritance relationship between the template and hook classes
Allows for behavior change at run time
1:N Connection
The template class refers to any number of instances of the hook class
There is no inheritance relationship between the template and hook classes
Allows for behavior change at run time
1:1 Recursive Connection
Same as the
Chain of Responsibiltiy
pattern and similar to the
Decorator
pattern
The template class refers to one instance of the hook class
The hook class is an ancestor of the template class.
Can model chains of instances
Allows for behavior change at run time
1:1 Recursive Unification
The degenerate version of the 1:1 Recursive Connection
The template and hook classes are the same class
Allows for behavior change at run time
1:N Recursive Connection
Similar to the
Composite
pattern
The template class refers to any number of instances of the hook class
The hook class is an ancestor of the template class
Can model trees of instances
Allows for behavior change at run time
1:NRecursive Unification
The degenerate version of the 1:N Recursive Connection
The template and hook classes are the same class
Allows for behavior change at run time