CSC/ECE 517 Fall 2010/ch3 3h ss: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
== The Strategy Pattern in Static and Dynamic Languages ==
== The Strategy Pattern ==


The Strategy pattern is a common design pattern that defines algorithms into familial groupings.  It encapsulates the individual algorithms and makes those algorithms interchangeable.  Strategy allows the algorithms to differ autonomously from the clients who use them. <sup>(1)</sup>
The Strategy pattern is a common design pattern that defines algorithms into familial groupings.  It encapsulates the individual algorithms and makes those algorithms interchangeable.  Strategy allows the algorithms to differ autonomously from the clients who use them. <sup>(1)</sup>

Revision as of 01:51, 6 October 2010

The Strategy Pattern

The Strategy pattern is a common design pattern that defines algorithms into familial groupings. It encapsulates the individual algorithms and makes those algorithms interchangeable. Strategy allows the algorithms to differ autonomously from the clients who use them. (1)

Static Languages

The use of the Strategy design pattern in static languages requires the relations between classes and interfaces to be referenced by extending classes, implementing interfaces, instantiating objects, invoking methods, etc. (2)

Java Example:

C++ Example:

Python Example:

Dynamic Languages

The use of the Strategy design pattern in dynamic languages requires a variable that has a function as the value. Separate classes are not needed in dynamic languages. (3)

References

(1) Head First Design Patterns Freeman & Freeman

(2) OBJECTED-ORIENTED DESIGN PATTERN DETECTION USING STATIC AND DYNAMIC ANALYSIS IN JAVA SOFTWARE

(3) Design Patterns in Dynamic Programming