Summary


This chapter discusses the Command pattern, which is a way of encapsulating an action and its parameters. The Command pattern is useful as a solution to a variety of scenarios such as the need for transactional behavior or undoable actions. Regardless of the way in which a command is used, it always implements a known interface that has, at a minimum, a method (execute()) that runs the action. In most cases, the command also has a receiver of the action, a client that instantiates the command, and an invoker that calls the method that runs the action. As shown by the examples in this chapter, the receiver, client, and invoker for a command change based on the way in which the command is used. In some cases, the client and invoker are the same object.

In the next chapter, we'll look at the Memento pattern, which is often used in conjunction with the Command pattern. In fact, in the next chapter we'll continue building the Proximity game application to use the Memento pattern.




Advanced ActionScript 3 with Design Patterns
Advanced ActionScript 3 with Design Patterns
ISBN: 0321426568
EAN: 2147483647
Year: 2004
Pages: 132

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net