|
Evaluating Software Design Patterns — the "Gang of Four" patterns implemented in Java 6 |
||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | ||||||||
See:
Description
| Class Summary | |
|---|---|
| CommandCreator<E,T> | A command creator creates commands to
manipulate a given receiver sequence using the
CommandCreator.getCommand(Sequence, Object) method. |
| EvilSequenceCommandCreator<E> | An evil sequence command creator is a test creator
that flips the functionality offered by the sequence command
creator, and may decide to
return a new evil command as a default command. |
| Factory<T> | A generic factory that will create products of type T. |
| Main | Factory Method tests. |
| ReflectiveCommandCreator<E> | A reflective command creator creates new
commands based on type literals as tokens. |
| ReversibleSequenceCommandCreator<E> | A reversible sequence command creator extends
the sequence command creator
to allow for the creation of reverse
commands for reversible sequences. |
| SequenceCommandCreator<E> | A standard command creator creates new
commands based on sequence states
as tokens. |
| TypedFactory<T,P> | A generic factory that will create products of type T while
only accepting constructor arguments of type P (for all arguments). |
Implementations and examples of the Factory Method design pattern [Gamma95, p.107].
Intent:
Define an interface for creating an object, but let sub—classes decide which class to instantiate. Factory Method lets a class defer instantiation to sub—classes.
Command interface
represents the Product participant, and a concrete
Command implementation represent the ConcreteParticipant
participant, for example NextCommand.
Hence, factory methods are defined to create commands. As explained in
the Command pattern, the commands
primarily use Sequence instances
as receivers, but some are receiver-less.
The CommandCreator
type represents the Creator participant, and a sub-class of it
represent a ConcreteCreator, for example
ReversibleSequenceCommandCreator.
The CommandCreater<E,T> class is parameterised with
the type of the Command (and Sequence) values as
well the type of tokens used identify the type of commands
to create. The ReversibleSequenceCommandCreator, and others,
use internal sequence states
as tokens, while the ReflectiveCommandCreator
class uses type literals
as tokens.
Furthermore, the generic Factory class
illustrates how reflection can be used to make a completely generic factory type
to create any type of instantiable product, providing the product type has a
usable constructor.
Implementation notes:
The log implementation
used in this thesis also illustrates the Factory Method pattern.
|
Gunni Rode / rode.dk | ||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | ||||||||