O'Reilly logo

ActionScript 3.0 Design Patterns by Chandima Cumaranatunge, William Sanders

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 11. Strategy Pattern

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 a design pattern should not be an inherent object-oriented way of thinking. Then they proceed to reject the Strategy design pattern 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 identical to the State design pattern, we need to spend some time distinguishing the Strategy from the State pattern to show not only ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required