Monday, March 02, 2009

Know your Customer :)

A disappointed salesman of Coca Cola returns from his Middle East assignment. A friend asked, "Why weren't you successful with the Arabs?" 

The salesman explained, "When I got posted in the Middle East, I was very confident that I would make a good sales pitch as Cola is virtually unknown there. But, I had a problem I didn't know to speak Arabic. So, I planned to convey the message through three posters... 




First poster 
- A man lying in the hot desert sand...totally exhausted and fainting.

Second poster - man is drinking our Cola.

Third poster- Our man is now totally refreshed.

Then these posters were pasted all over the place

"That should have worked," said the friend.

|

|

|



The salesman replied "I also didn't realize that Arabs read from right to left"


Develop Web services clients with Macromedia Flex

Flex the power of Web services by learning how to easily leverage them within a Rich Internet Application (RIA) using Macromedia Flex for a more complex, engaging, and interactive client-side experience. RIAs are an evolution of the traditional Web page based model for Web applications. A big part of the attraction in using Flex for RIA development is the speed and ease with which you can leverage Web services in your applications. The authors walk you through several examples and simplify how sometimes confusing WSDL constructs map to Flex declarations.


Selecting the Right Flex Application Framework

So you’ve decided to use Flex for your web application development. It’s easy to follow the online tutorials and prototype an application, but deciding on an application framework for your major production Flex application is more difficult. The Flex community is divided between Adobe’s Cairngorm and Cliff Hall’s PureMVC, with strong arguments from both sides. However, your answer may just lie in the “it depends” space.

This post aims to help you make that decision. It includes analysis of CairngormPureMVC, and the new kid on the block, asfusion’s Mate.

Cairngorm

Cairngorm (pronounced \kern-gorm\) is a lightweight micro-architecture for Rich Internet Applications for Flex or AIR applications. It is not only a framework, but also an approach to organizing and packaging code, components, and a method to achieve separation of concerns (i.e. model-view-controller).

Compared to other frameworks, Cairngorm requires the most components, but it is the most straightforward.

Cairngorm Framework
Figure 1 Cairngorm Framework


ProsCons
  • Advocated by Adobe Consulting and is part of the Adobe Engagement Platform.
  • Broadest adoption for a Flex MVC framework, making it the de facto standard for Flex developers
  • Well-documented with great tutorials.
  • Designed expressly for Flex and thus, takes advantage of Flex features.
  • Simple, straightforward MVC framework
  • Tightly couples the MVC layers.
  • Components can either be too large or too many, resulting in the application becoming too unwieldy from the development and maintenance perspective.

Tips and Tricks

  • Use packaging, sub-classing, or helper classes to prevent unwieldy model locators and controllers.
  • Use Adobe Consulting’s Observe Utility to prevent tight coupling between the view and the model locator.
  • Minimize direct references to the model locator from the view, by passing data references between parent and child components.

Recommended When:

  • The team and/or the organization are new to application development, ActionScript and/or Flex. It is good for new Flex developers to learn Cairngorm before other frameworks first. Management will also be more comfortable with an Adobe-backed framework.
  • You need a quick prototype.

PureMVC

PureMVC is also a lightweight framework for creating applications based on the classic MVC concept. PureMVC is not specific to Adobe Flex and is being ported to other languages. Many Flex developers consider the framework to be the best Flex framework out there, but accept that it does not take advantage of Flex features.

PureMVC Framework
Figure 2 PureMVC Framework


ProsCons
  • Provides flexibility to easily support complex workflows, e.g. command chaining.
  • Promotes code reuse.
  • Cleaner architecture and implementation, i.e. layers are more loosely coupled.
  • Well-documented, but not many tutorials.
  • Not designed expressly for Flex, and thus, has been criticized for not taking advantage of basic Flex features, such as data binding.

Tips and Tricks

  • Since the framework is language-agnostic, it cannot rely on data binding innately. But this doesn’t mean binding can’t be implemented in PureMVC Flex applications. Use the mediator to bind the data from the proxy to the view component.
  • Use a proxy for a service locator.
  • Reuse mediators for multiple view components.

Recommended When:

  • The application has complex logic and/or repeated logic.
  • If you need an MVC framework that cuts across the different languages of your application, e.g. Java and Flex. However, some of the PureMVC language ports are still in alpha.

Mate

Mate (pronounced \mah-teh\) is the newest Flex application framework. It is also designed expressly for Flex. Its main differentiator from Cairngorm is that it uses dependency injection to hook the event handlers to controller entities and view properties to the data model (via injectors). Thus, it requires the least number of components of all of the frameworks.

Mate Framework
Figure 3 Mate Framework


ProsCons
  • Provides flexibility to easily support complex workflows, e.g. method invoker chaining.
  • View can be simple and uncluttered, i.e. injectors can enable the view to not even reference Mate components, except for within the application MXML.
  • Promotes code reuse, e.g. invoked or referenced custom entities do not need to extend any base classes or interfaces.
  • Well-documented, including tutorials, examples and best practices.
  • Nullifies the power of AS3 compile-time type checking with the EventMap MXML.

Tips and Tricks

  • Flex events thrown must have its bubbling setting set to true.
  • Use multiple event maps to break down event type concerns.
  • Take special care in structuring and designing the controller entities.

Recommended When:

  • You need a really quick prototype.
  • The application has complex logic and/or repeated logic.
  • Your team has designers or component developers, not responsible for integrating the UI with the business services.
  • You have an existing Flex application that needs a framework refresh. You can quickly reuse the AS classes that have already been created and string them up using the event maps.

Others

  • Slide is Peter Joel’s work in progress. It has been released, but there is still a lot of work being done on it, and thus, little documentation is available. Its concept of view states by URIs and acknowledgement of data and navigation to drive view states is interesting though.
  • ARP (Ariaware RIA Platform) is Aral Balkan’s effort, borne from Flash 5. Its latest version finally supports Flex. It’s very similar to the Cairngorm framework with the inclusion of base classes for commands, controllers and forms. It also makes a distinction between system and view events. However, it doesn’t present a strong compelling differentiation from the Cairngorm framework, but seems to be a viable solution as well.
  • Foundry is another application framework, built for ActionScript and based on the MVC pattern, by Servebox. It is also very similar to Cairngorm, but heavily advocates the use of view helpers. Like ARP, the framework doesn’t provide a strong differentiation from Cairngorm, but seems to also be a simple, viable framework to use.
  • Guasax is a Flex application framework, but is not based on the MVC pattern. Like Struts, it uses configuration files to set up actions invoking business objects and setting up interceptors for those actions. At first blush, the framework seemed too complex, and examples online are not commented in English.
  • Flest is a Flex application framework that uses model, view, and controller components, but does not claim to be an MVC framework. The suggested use of the provided components is to tightly couple them within the application (e.g. commands are closures to the controller). Thus, it didn’t appear to be an ideal framework in easing maintenance of the application.
  • MVCS is an architectural blueprint for Flex applications, based on the MVC pattern. Joe Berkovitz’s article on Adobe Developer Connection is definitely worth the read. The concepts in the article are helpful when designing your application. But MVCS is not packaged as a reusable framework.

Sunday, March 01, 2009

Top 10 Adobe Flex Misconceptions

At QCon, Adobe's James Ward shared with InfoQ.com the top Adobe Flex misconceptions that he encounters in his travels evangelizing the Flex application framework.
  1. Users Need to Install Something New to Run Flex Applications. 

    Ward, exclusive to InfoQ.com, discusses the Flash adoption rates and Flex programming model:
    Flash Player 9 is required for Flex 2 & Flex 3. The Flash Player 9 runtime is currently installed on 94% of the world's computers:http://www.adobe.com/products/player_census/flashplayer/version_penetration.html 

    Flex 2 and Flex 3 applications execute in the Flash Player 9. Flex applications are built on top of the native Flash Player APIs like vector graphics, bitmap manipulation, and networking (which are based on the browser networking stack). The Flex framework adds reusable components like date pickers, data grids, charts, etc. Compiling a Flex application results in a SWF file which is the binary byte code format for the Flash Player. Contained in the SWF file is the byte code for the Flex framework code and a project's custom code. The Flex compiler optimizes the byte code so that only classes which are used go into the SWF file. 

    For desktop applications, Adobe is aiming to make their new desktop runtime, dubbed Adobe AIR, as ubiquitous as the web runtime. The 1.0 release of Adobe AIR will be available in the beginning of 2008. Currently, AIR is in beta release from labs.adobe.com. Many companies are already building production applications on AIR. One example, can be seen with eBay's application eBay Desktop.
  2. Flash Player is 100% Proprietary. 

    Ward continued on this item for InfoQ.com:
    The core of Flash Player is the Tamarin Virtual Machine, which is an open source project under Mozilla. While the SWF file format is not fully open, it is documented by the community on osflash.org. There are numerous open source products that read and write SWF files. The Flash Player's product direction has traditionally been heavily influenced by the community and their needs. The core language for Flash Player is an implementation of ECMAScript 262, which is the specification for JavaScript. Flex also uses CSS for styling of components / applications. Adobe AIR uses web standards as the basis for desktop applications as well as Open Source technologies like Tamarin, Webkit, and SQLite.
  3. Flash is for Designers, Video, and Annoyances. 

    In Ward’s July, 2007 blog, “How I Overcame My Fear of Flash,” he discussed this point:
    Indisputably, the power of Flash has been abused. Pop-ups, pop-overs, skip intros and annoying ads run rampant across our screens. I've heard it said that one should never judge a religion by its abuse. The same adage applies to technology. Flash shouldn't be avoided just because people use it for annoying things. After all, e-mail isn't avoided just because spammers happen to abuse it.
    Ward elaborated on the topic for InfoQ.com:
    Traditionally Flash content was built with the timeline based tool for designers. Flex is the developer toolset for building Flash based content / applications. Designers and developers can work together by sharing assets between the two tools. Flex adds a comprehensive component base: 

    http://www.adobe.com/go/flex_explorer_app 
    http://www.adobe.com/cfusion/exchange/index.cfm?event=productHome&exc=15&loc=en_us
  4. Flex is Not for Enterprise / Business Applications. 

    Over the last few weeks, Ward published a seven part blog series on a number of new Oracle applications implemented in Adobe Flex. The applications, which were announced at the recent Oracle OpenWorld, ranged from sales tools, to database management, and business intelligence.

    In addition to Oracle’s usage of Flex, InfoQ.com published a piece recapping a number of groups using Flex for enterprise applications. Ward also points out to InfoQ.com, that there are numerous examples of enterprise applications being developed with Adobe Flex, including work at: Workday, SAP, Salesforce, and Business Objects. 

  5. Flex is Expensive. 

    Ward detailed a number of things Adobe has done to address the cost concerns:
    Flex is a free, and soon to be open sourced, developer toolkit for building Rich Internet Applications for the web and the desktop. This free SDK includes everything a developer needs to build RIAs that work the same on any browser or operating system. Part of the free Flex SDK is an extensive set of components which are extensible, skinable, and accessible. You can see many of these components in the Flex Component Explorer: http://www.adobe.com/devnet/flex/samples/code_explorer/ 

    Flex Builder is an optional plugin for Eclipse which makes developing applications with the free Flex SDK more efficient. It includes features like integrated debugging, design view, and code completion. 

    The Flex Builder pricing has changed in quite a few ways recently. Flex Builder is now free for Students and Faculty. The price for the vanilla Flex Builder, without the charting components, has been reduced to $249 to better balance the tiered pricing for Flex Builder.

    There are a number of options for building backend infrastructure for Flex Applications. To take advantage of the high performance AMF data transfer protocol, there are official Adobe products like LiveCycle Data Services, as well as numerous open source projects like Granite Data Services. Using AMF removes the unnecessary steps of converting data to text (SOAP, RESTful, etc), transferring it, and then converting it back to data. AMF also allows type information to be preserved across the wire.
    To see a comparison of AMF to other text based serialization technologies, see James Ward's Census RIA Benchmark application: http://www.jamesward.org/census.

  6. Flex Applications Require a Special Server. 

    Once again, Ward speaking with InfoQ.com:
    Flex applications can run on top of any web server, application server, and database server. Flex applications are much more like client-server applications. Since the logic is running on the client inside the Flash Player, you need some way of communicating with the server. There are many different options for how you connect Flex to your infrastructure. Without any special libraries, you can expose your back-end data and services as RESTful, XML, or SOAP and easily consume that data in your Flex application. If you choose to use the AMF binary serialization protocol, you may need to add some additional libraries into your web application. AMF is just another serialization technology, like XML or JSON, so it can be one of the various methods you use to communicate to your back-end SOA.
  7. Flex is Hard to Learn. 

    Leftie Friele, from the InfoQ.com community, posted a comment on the InfoQ.com piece “Who is Using Flex?”, detailing his company’s experience in learning Flex:
    Our startup company, Ezmo, have used Flex since the start and we're extremely happy with the framework. 

    Without any prior knowledge of Flex/Flash, we built our application in less than two weeks. The integration between Java and Flex is super simple, and getting started with Flex is just a walk in the park. 

    The tool support is very good too with Flex Builder. You get the familiar surroundings of Eclipse and you are off and running without many problems. The one thing that is missing is better tools for continuous integration and better plugins into Maven for building Flex applications.
    For those new to Flex, Ward has a Screencast showing a Flex application being built to help get you started. There are also numerous other articles about using Flex and Java in the Adobe Developer Connection. 

  8. With Flex, I Will Need to Rebuild My Entire Application. 

    In January, Bruce Eckel published an article titled, “Hybridizing Java.” He argues that the Java community should continue using the good parts of Java, but should use other technologies where Java is weak. His primary focus in the article is using Adobe Flex for user interfaces, instead of the traditional Java options (Swing, JSF, etc…). 

    Ward elaborates on this concept:
    Since Flex applications are just the UI piece of an application the back-end usually stays the same. If your back-end was built following the SOA pattern then it is usually very easy to expose those services out to a new Flex UI. This preserves your existing business logic whether it is in EJBs, Spring services, POJOs, etc.
  9. Flex Breaks Normal Browser Functionality, Like the Back Button. 

    Ward’s blog discusses the back button:
    In Flex, back button support is built in and easily customizable so this was never an issue. Flex also provides an easy way to do hashmark urls (or named anchors), so the url changes as application state changes. Another Web 1.0 integration problem solved.
    Ward adds more details for InfoQ.com:
    Flex 3 provides a simple way for applications to store state parameters in a named anchor and correctly restore state based on those parameters when the URL is requested. More information about this feature can be found in the Flex 3 Feature Introductions Deep Linking documentation. 

    Accessibility has always been very important for Flex applications. Since the Flash Player works with Jaws and other accessibility technologies, the capability for adding accessibility to Flash based applications is there. The Flex framework builds accessibility into the core framework. There are many different pieces of accessibility depending on what impairments and disabilities your application needs to support. You can find out more about the accessibility features of Flex in the Developer's Guide.
  10. I Can Do Everything Flex Does With Ajax. 

    Ward explains:
    RIA with Flex and Ajax is not either/or. Sites like Google Finance show how you can use Flex and Ajax together. Ajax is very good for content-centric applications, while Flex is very good for interactive, media, and data-centric applications. If your application is somewhere in between the two sides of that spectrum, then you can use the Flex Ajax Bridge to combine the two technologies. In Flex 3, the Flex Ajax Bridge is integrated directly into the SDK. If you are using Flex 2, you will need to download the Flex Ajax Bridge separately.
    Also, from the InfoQ.com community, Michael Marth commented on why his group chose Flex:
    We use Flex 2 for our soon-to-launch online dating site viibee.com 

    The reason: Flex enabled us to create a user experience far beyond anything that we could have done with a comparable effort in Javascript/Ajax.