Chapter 6. Proxy Pattern


In This Chapter

Virtual Proxy 83

Remote Proxy 89

Adapter and Façade Patterns 94

Summary 94

The Proxy pattern gives us a solution to a very common programming task. A proxy is a class that stands in for and provides access to another object. This other object isn't always an ActionScript object. It could be an image file, an XML file, a Flash Remoting service, or a Web service.

There are many reasons for wanting to use a proxy object, and each reason has its own type of proxy. One reason you might want to control access to an object is because it is a remote resource; in such a case, the proxy object can manage the communication to and from that object. This is called a Remote Proxy, and we'll discuss it later in this chapter. Another reason to use a proxy is to defer the full cost of the object's creation. This could be because the object takes a long time to create or because the object uses a lot of resources once its been created. This type of proxy is knows as a Virtual Proxy, and we'll discuss it in the next section.

There are many types of Proxy classes; however, the Remote and Virtual proxies are the two most common, and the two we will cover in this chapter.

The Proxy pattern is often confused with a couple other patterns that are very similar in functionality. Those patterns are the Adapter and Façade patterns. The main distinction of a Proxy pattern is that is has the exact same API or interface as the object it is standing in for while both the Façade and Adapter patterns modify the API. We'll briefly touch on these two related patterns towards the end of the chapter.




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