8.1. What Are They?

Delegates are classes that are used as remote proxies. According to the article referred to earlier in this book, "Flex 3: Introducing Cairngorm" (Adobe Customer Training/Partner Enablement Group, Burleson, Shuman, and Boles), delegates have the following characteristics:

  • Each delegate provides a local proxy for a remote service.

  • Each delegate serves as a contract between client and server development teams.

  • They may hide underlying implementation details, including:

    • Client-side service lookups

    • Server API method invocations

    • Formatting of method arguments

    • Data transformations

  • Delegates allow for mock services and dummy data to be used while server implementations are resolved.

  • They are used in the control layer and should not be used outside it.

Delegate classes act as proxies for accessing remote services. It is the delegate class that performs the lookup of a service using the ServiceLocator.

Delegates are used in command classes that need to update or retrieve remote data. Since the delegate class handles the details of accessing the service, the command class only needs to know what function to call on the delegate and what type of data the service call is going to return.

In addition to hiding the details of service calls, delegates generally group related sets of service calls together. For example, a UserDelegate might contain functions for login, logout, and registering.

Delegates can also be used as stand-ins for live services that are still being developed, ...

Get Professional Cairngorm™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.