|
Evaluating Software Design Patterns — the "Gang of Four" patterns implemented in Java 6 |
||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Interface Summary | |
---|---|
ComparableExpressionBuilder<E extends Comparable<? super E>> | A comparable expression builder construct various Expression
types having a Comparable bound on the value produced by
the constructed expressions and/or on the expression operands used. |
ExpressionBuilder<E> | An expression builder construct various Expression
types having no bounds on the values produced by the
constructed expressions. |
Class Summary | |
---|---|
AbstractExpressionBuilder<E> | An abstract expression builder implements the basic
traits of the ExpressionBuilder interface, while
ensuring that the constructed terminal
expressions will all manipulate the same sequence
instance. |
CountingComparableExpressionBuilder<E extends Comparable<? super E>> | A counting comparable expression builder performs the same
functionality as a standard expression
builder, but also registers the number of times each expression type is
created based on expression names . |
CountingExpressionBuilder<E> | A counting expression builder performs the same functionality
as a standard expression builder,
but also registers the number of times each expression type is
created based on expression names . |
Main | Builder tests. |
StandardComparableExpressionBuilder<E extends Comparable<? super E>> | A comparable expression builder construct various Expression
types having a Comparable bound on the value produced by
the constructed expressions and on the expression operands used. |
StandardExpressionBuilder<E> | A standard expression builder construct various Expression
types having no bounds on the values produced by constructed expressions. |
TypedComparableExpressionBuilder<E extends Comparable<? super E>> | A typed comparable expression builder construct various
TypedExpression types having a Comparable bound on
the value produced by the constructed expressions and on the
expression operands used. |
TypedExpressionBuilder<E> | A typed expression builder builds typed
expressions. |
TypedFlowExpression<E> | A typed flow expression represents one or more expressions
to be evaluated in order, one at a time, where the type
of value the evaluation of the expressions produces associated with it
at runtime. |
Implementations and examples of the Builder design pattern [Gamma95, p.97].
Intent:
Separate the construction of a complex object from its representation so that the same construction process can create different representations.
ExpressionBuilder
and
ComparableExpressionBuilder
types,
and the ConcreteBuilder participant by any implementation
of either of them. The builders build
Expression
objects, and the Expression
interface thus corresponds to the Product participant. The overall
constructed root expression can be fetched using the
ExpressionBuilder.getRootExpression()
method.
Six concrete builders are provided, namely the
StandardExpressionBuilder
,
StandardComparableExpressionBuilder
,
CountingExpressionBuilder
,
CountingComparableExpressionBuilder
,
TypedExpressionBuilder
, and
TypedComparableExpressionBuilder
,
classes. The middle two performs the same functionality as the first two,
respectively, but also keeps track of the number of constructed
expressions, inspired by the Gamma et al. example in [Gamma95, p.104].
The last two creates TypedExpression
instances, but uses composition to allow another builder to perform the
actual creation.
Finally, the Director participant is represented by the
Main
class, which uses
the builders to construct Expression
objects.
Implementation notes: Overall idea based on the example from [Gamma95, p.189].
The TypedExpressionBuilder
illustrates good usage of covariant return types,
but also the problems that can be associated with it (see the class documentation).
|
Gunni Rode / rode.dk | ||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |