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

dk.rode.thesis.state
Interface StepSequence

All Superinterfaces:
Copyable<Sequence<Integer>>, Sequence<Integer>, StrictCopyable<Sequence<Integer>>, Stringable<Sequence<Integer>>
All Known Implementing Classes:
EvenSequence, OddSequence, StepSequenceImpl

@Participant(value="Context")
public interface StepSequence
extends Sequence<Integer>

A step sequence represents an unbounded integer value that is increased/decreased with a given step with each call to Sequence.next(). The step may be negative, but not zero.

A step sequence is unbounded, but unique and consistent.

Step sequences are created by the StepSequence.Factory.create(int, int) factory method.

Implementation notes:
A step sequence is implemented using dynamic proxies. It will appear to change its class (state) when the sequence value changes from even to odd or vice versa. This is done by altering the target object for the sequence methods in a dynamic proxy when the value "flips". Hence, the implementation of the sequence methods in effect changes. This imitates dynamic inheritance as described by Gamma et al. as the means to change the internal state [Gamma95, p.309].

Author:
Gunni Rode / rode.dk

Nested Class Summary
static class StepSequence.Factory
          A factory to create StepSequence instances.
 
Nested classes/interfaces inherited from interface dk.rode.thesis.meta.model.Sequence
Sequence.State
 
Method Summary
 
Methods inherited from interface dk.rode.thesis.meta.model.Sequence
bounded, consistent, copy, current, next, reset, state, unique
 
Methods inherited from interface dk.rode.thesis.strategy.Stringable
getStringablePolicy, toString
 


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.