Evaluating Software Design Patterns
— the "Gang of Four" patterns implemented in Java 6

@Pattern(name="Strategy", scope=Object, purpose=Behavioural, participants={"Strategy","ConcreteStrategy","Context"})

Package dk.rode.thesis.strategy

Implementations and examples of the Strategy design pattern [Gamma95, p.315].


Interface Summary
Stringable<T extends Stringable<? super T>> A stringable object can be formatted into different textual char sequence representations using a given policy to determine the format.
StringablePolicy<T> Returns a textual representation in form of a char sequence of a given stringable object.

Class Summary
Main Strategy tests.
StringablePolicy.NameIdiom An idiom that allows the retrieval of a given StringablePolicy defined as an enumeration constant based on an exact name of another, possibly unrelated, policy.

Enum Summary
ObjectPolicy Standard policies for formatting any type of Object into textual representations in form of char sequences (appendable) or as strings (immutable).
SequencePolicy Default policies for formatting Sequence objects into textual representations in form of char sequences.
StringablePolicy.Type A policy type is a hint a stringable context can use to decide how to use the textual representation a given policy generates in conjunction with additional textual information required to generate an overall representation.

Package dk.rode.thesis.strategy Description

Implementations and examples of the Strategy design pattern [Gamma95, p.315].


Here, the Strategy participant is represented by the StringablePolicy interface that allows the Context participant in form of Stringable objects to have numerous different textual representations. As Sequence implements the Stringable interface, any sequence implementation is thus a representation of the Context participant.

The enumerations ObjectPolicy and SequencePolicy represent the ConcreteStrategy participant, each defining many different policies (strategies) for formatting Object and Sequence instances, respectively.

UML Class Diagram:

Gunni Rode / rode.dk

Gunni Rode / rode.dk

Feel free to use and/or modify the Java 6 source code developed for this thesis AT YOUR OWN RISK, but note that the source code comes WITHOUT ANY — and I do mean WITHOUT ANY — form of warranty WHAT SO EVER!

The original thesis and source code are available at rode.dk/thesis.