• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
View the presentation deck (powerpoint)

View the presentation deck (powerpoint)






Total Views
Views on SlideShare
Embed Views



0 Embeds 0

No embeds



Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    View the presentation deck (powerpoint) View the presentation deck (powerpoint) Presentation Transcript

    • AFFUG Presentation Exploring the Flex Data Services Framework: From Prototypes to Large-Scale Applications October 15 th 2008 Page
    • What we’ll cover today
          • Overview of Flex Data Classes
          • Deep dive into some of the key classes you need to know
          • Discuss concepts, approaches and consideration when developing apps from prototypes to large scale projects.
          • Quick look at some of the Adobe and 3rd party Application micro-architectures
          • Get into some code
            • Explore 4 different stages of a single application: Yahoo! Image Search app
            • Balance of rapid prototyping with scalable architectures
          • Go home and watch the debates!
    • a little about me…
      • Early days
          • B.S. in Computer Engineering from Georgia Tech
          • Java as first (programming) language…then worked with EVERYTHING else
          • Started work in the ‘real world’ at 19 - Siemen’s Telecom and Motorola
          • Built my first Flash (4) sites in ‘97. And yes, a couple had skip intro movies…
      • Life in the Wild
          • Graduated in August. Career Fair on Sept 10 th & 11 th … 2001.
          • Good grades gave me a choice: $$$ || knowledge. I chose the latter.
          • Helped start an enterprise J2EE Portal with Federated Dept. Stores.
          • Art School on the side - Interactive Media Design
          • Started with Flex 1.0 Presentation Server. Flex as a JSP taglib?!
      • Livin’ Large
          • Began work as a Flex contractor…overtime pay is great.
          • Enterprise VOIP UI Team Lead with BellSouth
          • (Flash 8 + AS2) * Large Enterprise App = Pain
          • Senior Technical Architect + UX Designer = Nirvana
          • I’d love to show you what I’m working on right now, but then I’d have to ki…
    • a little about you…
      • With a show of hands…
        • How many of you have worked with Flex before?
          • If yes, how much experience? 6 mo. or more? A year or more? 2-3? Pros?
          • If no, how have you heard about it or become interested in it?
        • How many have worked with Flash but are new to Flex?
        • How many come from a different background and work with Flex only a little or are just learning?
        • Java?
        • Web? (HTML, JavaScript, CSS, AJAX)
        • Other?
        • Anyone not interested in Flex? …maybe in an hour or two you’ll change your mind!
    • Key data service classes and how they interact
    • To listen? Or to respond? Listening
      • Event subscription through addEventListener() establishes a relationship between a dispatching class and a receiving function until removed.
      • Its like getting into a committed relationship with a person. You have to listen to every single thing they say even if you didn’t ask for it! It only ends when you break it off.
      • Consider listening to service results only when you are certain that your event recipient is truly interested in processing ALL of the responses.
      • Fault handlers are often listeners even when associated response handlers are responders.
      • Responders are associated with a particular request using AsyncToken’s addResponder(). They only get called once in response to the request for which they are associated.
      • Following the relationship analogy, I guess this would be like ‘friends with benefits’. If you give them a call, they’ll be there in a heartbeat, but otherwise they just leave you alone!
      • Consider responding to service results when you need to process individual requests or you are building a (stateless) common service that must handle multiple, simultaneous requests.
      • Responding can occur at multiple levels.
      Responding As with many decisions related to software architecture and design, there isn’t just one ‘right’ way to interact with data services. Instead, you have a number of supported interactions, each of which has its own place and purpose. The two primary interaction patterns are: (Event) Listening & Responding (to a request)
    • mx.rpc.AsyncToken
      • The AsyncToken class:
          • Is a dynamic object that is returned from the send() method of service classes
          • Serves as the conduit between an asynchronous request and its corresponding response.
      • Three fundamental benefits to using the AsyncToken:
          • A simple means for the consumer of a service to interact with only the request it initiates.
          • A persistent object associated with a service request that can be shared with multiple parties (classes, etc.) that are interested in participating in the processing of the response without their explicit involvement in the request itself.
          • As a dynamic class, it can provide the correlation of a service request’s input data, or other similar contextual information, with the associated response.
          • public dynamic class AsyncToken extends EventDispatcher {
            • public function addResponder(responder:IResponder): void ;
              • public function get result():Object;
              • public function hasResponder():Boolean;
          • }
    • mx.rpc.IResponder
      • package mx.rpc {
          • /**
          • * This interface provides the contract for any service that needs to respond to remote or asynchronous calls.
          • */
          • public interface IResponder {
            • /**
            • * This method is called by a service when the return value has been received.
            • * While <code>data</code> is typed as Object, it is often
            • * (but not always) an mx.rpc.events.ResultEvent.
            • */
            • function result(data:Object): void ;
            • /**
            • * This method is called by a service when an error has been received.
            • * While <code>info</code> is typed as Object it is often
            • * (but not always) an mx.rpc.events.FaultEvent.
            • */
            • function fault(info:Object): void ;
          • }
      • }
    • mx.collections.ItemResponder
      • package mx.collections {
          • import mx.rpc.IResponder;
          • public class ItemResponder implements IResponder {
            • public function ItemResponder(result:Function, fault:Function, token:Object = null ) {
              • super ();
              • _resultHandler = result;
              • _faultHandler = fault;
              • _token = token;
            • }
            • public function result(data:Object): void {
              • resultHandler(data, _token);
            • }
            • public function fault(info:Object): void {
              • faultHandler(info, _token);
            • }
            • private var _resultHandler:Function;
            • private var _faultHandler:Function;
            • private var _token:Object;
          • }
      • }
    • A Tale of Two Tokens
      • AsyncToken
          • Dynamic class created by a service when a request is made through the send() function.
          • Can be passed to multiple classes interested in the transaction (Services, Views, Controllers).
          • Each class that has access to the token can participate in the response (result or fault).
          • As a dynamic class, each and every responder can interact (mess with) dynamic properties.
            • Both a Pro and a Con!
      • ItemResponder’s data token
          • Optional parameter in the ItemResponder’s constructor.
          • Typed as Object, so it can be just about anything you want it to be.
          • Provides a means of establishing local contextual data for a response (result / fault pair)
          • Since it is a local, dynamic object, nobody else can mess with it!
    • Keeping data parsing at the service level
      • Problem
      • So, you followed the best practices of MVCS and created:
        • Service Façade Interfaces - abstract service details and centralize service processing. Translate response data (XML) in to Data Models and vice-versa.
        • Strongly-type Data Models - common data structures that insulate Views from service and schema changes.
      • If I use AsyncToken as the return value for all of my services, then don’t all of the components that receive the response have to translate the raw data into models?
      • How do I keep that encapsulated in the service classes?
      • Solution
      • The service establishes itself as a responder. It will be called first since it registers first.
      • The service then translates result data into models and attaches them to the token.
      • Each subsequent responder now has access to the pre-processed models.
      • Caution
      • This solution relies on non-typed properties of a dynamic object as the contract between the service and its consumers.
      • Each consumer (responder) has the opportunity to mess with the dynamic properties that subsequent responders rely on.
    • Multiple Participation (Is that even allowed in this state?!)
    • Many other options
      • Many Flex-based Application Frameworks exist that provide similar or enhanced capabilities beyond what is capable with the standard Flex 3 framework components covered today.
      • Some popular application frameworks:
          • Cairngorm micro-architecture
          • Free. Originally conceived by iteration::two who later became part of Adobe Consulting.
          • http://opensource.adobe.com/wiki/display/cairngorm/Cairngorm
          • PureMVC
          • Free. Two version available: Standard & MultiCore, which supports multiple PureMVC apps in 1 VM.
          • http://puremvc.org/
          • Model-Glue: Flex
          • http://www.model-glue.com/flex.cfm
          • ServeBox Foundry
          • http://www.servebox.com/foundry/doku.php
          • Guasax
          • http://www.guasax.com/blog/
          • Mate
          • Mate is a tag-based, event-driven Flex framework
          • http://mate.asfusion.com/
    • Lets see some code already!!!
    • Sites referenced during the presentation Ely Greenfield Architect on the Flex SDK Team Quietly Scheming: http://www.quietlyscheming.com/blog Doug McCune Universal Mind Blog: http://dougmccune.com/blog/ Programmable Web Mashups - Web 2.0 APIs - Web as a Platform http://www.programmableweb.com/ Yahoo Image Search http://www.programmableweb.com/api/yahoo-image-search Flex 3 Regular Expression Explorer Created by: Ryan Swanson Blog: http://blog.ryanswanson.com/2008/10/introducing-flex-3-regular-expression.html Application: http://ryanswanson.com/regexp/