10.12.2012 Views

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Now that you have an abstract Strategy design pattern where you can see the arrangement<br />

of the different parts, an illustration where you can see all of the connections,<br />

delegation and interactions in a single view will give you an overview of the process.<br />

Figure 11-3 shows the connections between the different parts, all in one view.<br />

Figure 11-3. Delegation connections<br />

In Figure 11-3, note how the call:<br />

thinker.doStrategy( );<br />

is delegated. The thinker instance in the TestStrategy class is typed as a Context type<br />

and instantiated as a ConcreteContext object. The doStrategy( ) method is created in<br />

the Context class, and so that would be the first place to look, as the arrow from<br />

doStrategy( ) in the TestStrategy class to the doStrategy( ) in the Context class<br />

shows.<br />

However, in the Context class the doStrategy( ) method has delegated the details to<br />

the think( ) method, so we need to look elsewhere. In the ConcreteStrategy class, you<br />

can see the details of the think( ) method. Because the ConcreteContext strategy is<br />

instantiated in the thinker instance, it actually did the work, but since ConcreteContext<br />

is a subclass of Context, the delegation is structured in the Context class.<br />

Finally, we can trace the delegation framework back to the Strategy interface.<br />

Because the origin of the think( ) method is in the Strategy class, we can see how it<br />

is a delegate of the Context class.<br />

Minimalist Abstract State Pattern | 405

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!