|
Evaluating Software Design Patterns — the "Gang of Four" patterns implemented in Java 6 |
||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Interface Summary | |
---|---|
Character | A character represents a letter, symbol, or whitespace
in a Word . |
Textual<T> | A textual object represents a flyweight object that is a char sequence and comparable to its own type. |
Class Summary | |
---|---|
AbstractCharacter | An abstract character implements the basic traits of
the Character interface. |
CharacterFactory | A character factory creates and manages Character ,
Word , and Sentence objects. |
Letter | A letter represents a single letter that
is not a whitespace or contain
symbolic characters. |
Main | Flyweight tests. |
Sentence | A sentence represents an ordered sequence of
words making up that sentence. |
Symbol | A symbol represents a single symbol that
is not a whitespace or a letter . |
Whitespace | A whitespace represents a single white space character. |
Word | A word represents an ordered sequence of characters
making up that word. |
Enum Summary | |
---|---|
CharacterPolicy | Default policies for formatting Character objects
into char sequences (not part of the core Flyweight
implementation). |
Implementations and examples of the Flyweight design pattern [Gamma95, p.195].
Intent:
Use sharing to support large numbers of fine—grained objects efficiently.
Textual
interface.
This package supplies three flyweight types, namely the
Character
interface and
the Word
and
Sentence
classes.
A standard abstract implementation of the Character
interface
is supplied in form of the AbstractCharacter
class, and each implementation corresponds to the ConcreteFlyweight
participant, for example Letter
and Symbol
.
The Word
class also represent the ConcreteFlyweight
participant, while the Sentence
class represents the
UnsharedConcreteFlyweight participant.
Flyweights are constructed using the FlyweightFacctory
participant, which is represented by the
CharacterFactory
class.
The Client participant is the test application, i.e. the
Main
class.
Implementation notes:
Both Word
and Sentence
are in fact implementations
of the ArraySequence
class:
the elements of a sentence is the words it contains, while the
elements of a word is the letters it contains. Hence, Sentence
,
Word
, and Character
objects form a
Composite-like structure. This fits
very well with the general semantics of Sequence
, for example
that any Word
must have at least one Character
,
or a Sequence
at least one Word
.
All textual flyweights in this package are also
Stringable
.
The internal states used by the ReversiblePrimeSequence
class can be seen as a degenerate application of the Flyweight pattern.
|
Gunni Rode / rode.dk | ||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |