ActionScript 3.0 Design Patterns

(Chris Devlin) #1

398


Chapter 11
CHAPTER 11


Strategy Pattern 11


Enact strategy broadly, correctly and openly. Then
you will come to think of things in a wide sense and,
taking the void as the Way, you will see the Way as
void.


—Miyamoto Musashi (16th-17th Century Japanese
developer of Sword Method Design Pattern [Kenjutsu]
and guy who reminds us that in ActionScript 3.0, the
void statement is all lowercase.)


All men can see these tactics whereby I conquer, but
what none can see is the strategy out of which victory
is evolved.


—Sun Tzu


However beautiful the strategy, you should
occasionally look at the results.


—Winston Churchill (Remark made after finishing up a
“Hello world” application using the Strategy pattern.)


What Is the Strategy Pattern?


The Strategy design pattern is sometimes used to illustrate good OOP practices


rather than offered as a design pattern that has focused applications. In one article


[Agerbo and Cornils, 98], the authors set up a number of guidelines for judging


design patterns. One guideline posits that adesign pattern should not be an inherent


object-oriented way of thinking. Then they proceed to reject the Strategy design pat-


tern because it seems to be nothing but a collection of fundamental OOP principles!


Whether the Strategy pattern is a true design pattern or just a template for how to go


about OOP programming, it has lots to offer. Because the class model looks identi-


cal to the State design pattern, we need to spend some time distinguishing the Strat-


egy from the State pattern to show not only how each is unique, but to suggest focal


applications each may have.

Free download pdf