The Strategy Pattern
An Introduction with Examples in Java
|
Prof. David Bernstein
James Madison University
|
|
Computer Science Department
|
bernstdh@jmu.edu
|
An Example of the Strategy Pattern (cont.)
The "Strategy" Interface
javaexamples/math/Metric.java
An Example of the Strategy Pattern (cont.)
Some Implementations
javaexamples/math/EuclideanMetric.java
An Example of the Strategy Pattern (cont.)
Some Implementations (cont.)
javaexamples/math/RectilinearMetric.java
An Example of the Strategy Pattern (cont.)
Some Implementations (cont.)
javaexamples/math/SupremumMetric.java
An Example of the Strategy Pattern (cont.)
The "Context"
javaexamples/strategy/Posterizer.java
There's Always More to Learn