Selecting the Right Flex Application Framework

January 14th, 2009 Via Tsuji, Consultant  (email the author)

This entry is part 1 of 6 in the series Flex Development

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 Cairngorm, PureMVC, 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


Pros Cons
  • 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


Pros Cons
  • 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


Pros Cons
  • 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.

Be Sociable, Share!

Entry Filed under: Agile and Development

33 Comments Add your own

  • 1. So - how Flexible are you&hellip  |  January 19th, 2009 at 3:16 pm

    [...] development community and how much momentum and support it has already gained.  As you can see by Via’s post – our company is excited about Flex and we are going try to post serious content to aide more [...]

  • 2. Anilkumar GT  |  January 20th, 2009 at 3:24 am

    Excellent summarization Summa …. i like the diagrams as well….

    I think the examples and documentation for PureMVC are excellent (this is a con in your article) … Cairngorm did not have good examples earlier…but in the recent past that has improved as well..

  • 3. Via Bulatao  |  January 20th, 2009 at 9:51 am

    Thanks, Anilkumar!

    I think PureMVC’s documentation is great. Unfortunately, I didn’t manage to find any tutorials. But once I learned Cairngorm using theirs, I got to working quickly with PureMVC.

    Later on, I found this article, which helped as well: http://www.dehats.com/drupal/?q=node/26. The author had a good exchange with Cliff Hall in the comments.

  • 4. Don Zerly-Lite  |  January 20th, 2009 at 10:04 am

    In your Cairngorm graphic, the Model layer references an EventBroadcater

    Perhaps BroadcaSTER ?

    Really NICE overview, BTW. I agree that many Flex quickstarts just show how to build interfaces with basic logic. I don’t want to go down that path when best practices always include dev frameworks.

    Could you provide a follow up article with a basic example of what part of the code goes where?

    For example, an employee want to update her home address in a database. Or a customer wants to change shipping information on an invoice.

    I’d benefit from an article that maps out the series of events through each framework. What does the FrontController do in the employee example? What does the ModelLocator or the Command/Delegate do in the shipping example?

    Looking forward to your next post.

  • 5. Via Bulatao  |  January 20th, 2009 at 11:46 am

    Thanks for the feedback, Don!

    You are correct on the Cairngorm diagram. That’s a typo.

    The analysis was derived after playing around with code built using each framework. However, the post was meant to help in the selection of a framework, when you don’t have much time to look at the code. What I’ve realized from writing this post is that sometimes, it’s not always about the code. Other factors may heavily weigh in on your decision to choose one framework over another, even if you conclude the other framework is better, design- and code-wise. At that point, you just have to derive best practices for the chosen framework, reversing its cons as much as you can.

    I am definitely looking forward to following up this post with a more detailed comparison of each. Thanks for requesting it. I agree with you that I struggled with how the quick starts showed just basic logic, with little to comment on best practices (with the exception of Mate). So I will veer away from that.

    Thanks again for stopping by! Watch out for our other Flex posts. More to come!

  • 6. ceaseoleo  |  January 20th, 2009 at 6:10 pm

    i looked into all 3 of these, as well as prana framework.. which has now been adopted under spring umbrella – known as spring actionscript. When I made the choice it was prior to this , but I went with pure mvc. Documentation, and examples are excellent , possibly a higher learning curve but if you come from java development background its very easy to pick up. I think the action script and tag magic that mate introduces was harder for me to grasp. Pure mvc’s extensibility in plugins and performance are amazing. The dev community is even better, most of the contributors are very bright and very active. But if I were to start over, I would probably go with prana /cairngorm at this point

  • 7. Via Bulatao  |  January 21st, 2009 at 9:40 am

    Thanks, ceaseoleo! I will definitely look into the Prana framework as well. I didn’t find it when I was doing research for this post.

    I agree with all your points on PureMVC. For Mate, I think it’s easy to grasp if you’ve used Spring, which makes me more curious about the Prana framework. I’d also be interested to understand your last comment on why Prana/Cairngorm after working with and being happy with PureMVC.

  • 8. Glen  |  January 24th, 2009 at 12:44 am

    It is a good summary. Is it possible to download this article in pdf file? Do you have any demos to compare performs of the frameworks (including core Flex – w/o using any these frameworks)?

    Thanks

  • 9. Via Bulatao  |  January 27th, 2009 at 11:03 am

    Currently, there is no way to download the article in PDF.

    I also don’t have a demo comparing the performance of core Flex with the frameworks. But that is a good idea for a follow-up post. However, we have successfully implemented Flex at our clients using Cairngorm without any reported performance issues. I think with the absence of a framework, you’ll still end up structuring your Flex application (assuming it’s not too simple and you’re working in a team environment) as if it had a framework to encourage code reuse within your application. If you’re going to end up doing it that way, anyway, you might as well use an application framework from the options described in this post.

    Thanks for stopping by, Glen.

  • 10. turin  |  February 2nd, 2009 at 5:45 pm

    you didnt mention Swiz
    Swiz http://code.google.com/p/swizframework/

  • 11. turin  |  February 2nd, 2009 at 5:59 pm

  • 12. Minh Tran  |  February 4th, 2009 at 12:53 am

    you may also need to include great framework swiz at http://www.onflex.org/ted/2008/09/360flex-sj-2008-introduction-to-swiz.php

    This is even simpler than Mate.

  • 13. Ka Wai  |  February 4th, 2009 at 1:07 am

    I’d highly recommend taking a look at the X2O Framework (www.x2oframework.com). Not at all an application framework– but it works with all the ones above.

    X2O is a web-based data modeling platform for Flex (and Flash CS4) apps that generates the server-side infrastructure (database, server-side, web services) as well as generated AS3 value objects in a SWC file. You don’t have to do any rpc or remoting integration. It handles all the backend integration for you and you get strongly-typed AS3 objects in your SWC. It also has nice features like file uploading and email object (all the server infrastructure is already set up).

    Instead of having to build all the tedious database/server-side backend that comes with a db-driven Flex app, it lets you focus on Flex programming. You have all your data management built automatically. Its a much cleaner and higher-level solution than something like direct PHP/MySQL or SQL/.NET to Flex setup since there’s no need to work in another language.

  • 14. Via Bulatao  |  February 4th, 2009 at 10:10 am

    Thank you for all the additional references to other Flex application frameworks! Definitely something to include for a future update to the article.

    From the little that I’ve read, it seems that Mate, Prana, Aconcagua and Swiz are in a similar IoC boat. All of which can be attached to Cairngorm or PureMVC or stand on its own.

    However, Mate, IMO, is still the most different from the rest in that the configuration is not just for dependency injection but orchestration, as well. Whether that’s good or bad depends on the complexity of the project. Mate would have more difficulty handling complex event flows.

    I would wait and see what happens to Prana before using it on a project that starts tomorrow, though. I’m looking forward to its Spring ActionScript switch and addition of the MVCS support. Maybe then, I’ll rewrite this article.

    Aconcagua still seems raw to me. Documentation is limited to examples. No how-to’s. I still don’t understand why their beans, modules, and MVC support is separately packaged.

    I agree that Swiz is definitely something to consider. I wouldn’t say it’s easier than Mate. Wiring is easier. But Swiz is different in that Mate has a controller, while you have to build a controller in Swiz. This would be better for complex applications. But I do like how Mate view components do not have Mate code in them, but I agree this can be both good and bad.

    I wasn’t able to explore the X2O framework in more detail. But since the

  • 15. Glen  |  February 9th, 2009 at 4:25 pm

    You can check here to compare the performance on MVC frameworks.

    baoandassociates.com#selectedTab=3

    I do not think we need too many frameworks on Flex and learn the lesson from Java.

  • 16. The Flex Application Fram&hellip  |  February 19th, 2009 at 9:34 am

    [...] Selecting the Right Flex Application Framework post provided a summary comparison of the Flex application frameworks out there, highlighting the [...]

  • 17. Murugavel  |  February 19th, 2009 at 11:26 am

    It’s really a good tutorial.

    I have been working on a flex based web project where we need to handle multiple views. Say for example two same screens with diffrent data. Basically we have window kind of an functionality(maximize,minimize) in web. So the user can open two screen but they will allowd to enter different data.

    If I use cairingorm, the model objects are singleton. It’s very difficult to keep the state of the screen when the minimize and maxmize.

    Could you please tell me what architecture best suite above need? if you can mail me the details it would be great..

  • 18. Via Bulatao  |  March 3rd, 2009 at 9:06 pm

    @Glen, I wasn’t able to access the link you provided. But wouldn’t the performance comparison be measuring performance on the client? Is there really a big difference. I think that the mushrooming of Flex frameworks have improved from what we learned from Java. I mean most have leaped to DI, with some exceptions sticking to Struts-like models. But I think the variety highlights that no framework is perfect, and I think that’s always good to improve on the frameworks. But yes, making a decision can be confusing, which is why I created this post.

    @Murugavel, your description of the application is unclear. If you’re using multiple browser windows, I think no single Flex application framework will work for you, by itself. You’ll need some type of scripting to help you along. So I’ll urge you to question why you need to use multiple browser windows. That may make your solution simpler.

  • 19. Amar Shukla  |  March 17th, 2009 at 12:06 am

    Really a nice tutorial . Good work Via . I am always doubtful about adopting a framework for flex as all looks alike to me . Might be coz I am new to development , so this article gave me a good idea and now I wanna start with Cairngorm. Thnx alot for the article.

  • 20. Joy of coding » Int&hellip  |  March 17th, 2009 at 1:37 pm

    [...] http://www.summa-tech.com/blog/2009/01/14/selecting-the-right-flex-application-frameworks, Selecting the Right Flex Application Framework [...]

  • 21. ????? » Blog Archiv&hellip  |  April 1st, 2009 at 9:48 am

    [...] ???????Flex????(2009/01/14) [...]

  • 22. AjaxSucks  |  May 15th, 2009 at 4:08 pm

    I think the “disadvantage” of Swiz mentioned above is also a strength. The fact that it doesn’t force you to use a “SwizController” or something leaves it up to you to decide how to engineer things. It sounds more flexible–the only catch being that this may make Swiz better for more experienced devs (than new ones) compared to Mate since Mate guides (but also constrains) you more.

  • 23. Amit  |  July 22nd, 2009 at 4:34 pm

    Thanks for summarizing all ( most ) of the framework. I am J2EE developer new to Flex
    and looking for best practices and framework to use for FLex development.
    This gives me all the required pointers.
    Its very nice of you that you just not only write something good and informative
    but are active with comments .That are really helpful.

  • 24. aswini  |  August 24th, 2009 at 6:27 am

    Nobody mentioned about Fireclay…
    If anybody has some docs kindly ley me know

  • 25. Flex Framework « iu&hellip  |  September 16th, 2009 at 6:19 am

  • 26. Muhammad Umair  |  April 20th, 2010 at 11:35 am

    Thanks for such a great article, in the end I would say the Cairngrom wins the race.

  • 27. Ganesh Tiwari  |  July 17th, 2010 at 7:53 am

    i was searching for similar article for 2 weeks……. great article.
    thank u very much.
    i am planning to use Cairngorm…

    goto http://www.davidtucker.net/category/cairngorm/ for great resource about Cairngorm.

  • 28. Aneesh Sebastian  |  August 25th, 2010 at 8:04 am

    Can someone help me to choose the best J2EE flex compact framework. I need to develop a J2EE application which probaly will be having lot of Video streaming facility. Hence I think to go with Flex as UI. Iam aware of Struts and Spring. Is it suitable for Flex. Please advice.

  • 29. Aneesh Sebastian  |  August 25th, 2010 at 8:09 am

    Is Struts2+Flex3 is a good combination. Would I be able to easily merge Flex UI in struts2? Can u get me more details on this? I need to finalize application framework ASAP , so I can start learning.

  • 30. skoganti  |  December 21st, 2010 at 4:08 am

    Can you also come up with Parsley framework, help me to know when it is recommended?and how its advantageous over cairngorm.?

  • 31. Chris  |  July 6th, 2011 at 4:05 am

    check out robot legs when you have time ;)

  • 32. Marquita Hunnicutt  |  October 3rd, 2011 at 4:29 am

    I have been absent for some time, but now I remember why I used to love this site. Thank you, I will try and check back more often. How frequently you update your site?

  • 33. Local Business Reviews  |  July 23rd, 2014 at 12:34 am

    Greetings from Los angeles! I’m bored to death at work so I decided
    to browse your blog on my iphone during lunch break.
    I enjoy the information you provide here and can’t wait to take a look when I get home.
    I’m surprised at how quick your blog loaded on my mobile ..
    I’m not even using WIFI, just 3G .. Anyways, good site!

Leave a Comment

Required

Required, hidden


5 + six =

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed

© 2010-2014 Summa All Rights Reserved