Philosophy: Create opportunities through the evolution of technology and innovation.

Technology

Technology

We are privileged to create technology products and services that make a meaningful difference and impact in our client's businesses and the world around them.

  • Techonology
  • Tech Talk - Cairngorm Flex Binding vs PureMVC Observer Notifications

Cairngorm Flex Binding vs PureMVC Observer Notifications

By: Salem Artin

I recently participated in a development project that created two Rich Internet Applications (RIAa). Both projects used Adobe Flex as the framework for the user interface and Java for the server side. As usual, whenever you work on a multitier application a considerable effort is spent on making sure the user interface code (i.e. the view) does not get cluttered with the business logic code! As you might expect, we needed to put serious thought into our MVC (Model-View-Controller) meta-pattern.

To avoid reinventing the wheel, I looked into a "good" MVC implementation for Flex and landed on quite few options. Among the list were Cairngorm and PureMVC. Lucky circumstances meant that I had the opportunity to try out both frameworks, using one for each project!

Since both frameworks are open source, I spent considerable hunting for details and examples on how to "best" employ each one in my work. Halfway through my analysis, I needed to reach out to the open source community with my humble observations on both frameworks. Let's start with a quick comparison between Cairngorm and PureMVC before zooming in on what I found was the one of the key differences between each one.

  • Both frameworks were originally driven by the current need to properly design RIAs
  • Both are pattern-based.
  • Although PureMVC was originally implemented in the ActionScript 3 language for use with Adobe Flex, Flash and AIR, it has been ported to all major development platform like Java, Objective C, PHP and .NET (PureMVC website http://trac.puremvc.org/PureMVC_CSharp/ presents a demo that implements the framework for a Silverlight project). On the contrary, Cairngorm is implemented in Flex only and is geared to promote Flash and Flex framework as an ideal solution for RIA
  • Both addresses/implements the classic MVC meta-pattern where application architectures revolve around three tiers: Model, View and Controller

While we're mentioning the MVC meta-pattern, here is a simple diagram that illustrates its philosophy as implemented in Cairngorm

Note that:

  1. The data model communicates with the view via Flex framework binding. The model should never have any knowledge of either the controller or the view.
  2. The view contains code (usually Flex tags) that knows how to draw itself: these are the visual components in the view.
    • The view also contains also the code that reads data from the model to be rendered in the view.
    • The view should never modify the data model since this is the responsibility of the controller. This violates the purpose of MVC!
  3. The controller is responsible for providing responses to user gestures or any other events in the application.
    • Responses take place as changes and updates to the data model.
    • Sometimes, the response could be trivial enough as in enabling or disabling a UI element. In such case, you can save the controller a trip to the model then to the view by directly modifying/updating the view.
  4. Both are pattern-based

Proxies v.s. Delegates

Flash Events and EventDispatcher classes (which are ActionScript native) vs. environment-neutral Observer design pattern implementation.

Since PureMVC applications may run in environments without access to Flash's Event and EventDispatcher classes, the framework implements an Observer notification scheme for communication between the Core MVC actors (Model, View and Controller) and other parts of the system in a loosely-coupled way.

We know that PureMVC design revolves around three tiers: Model, View and Controller. Those tiers are also called Core actors, which each governed by one singleton.

PureMVC also uses a Facade to simplify the job of developing RIA. This Facade acts as a single interface via which developers interact with the Core actors

You'll read more about these in this space as the projects iterate and our use of these frameworks expands and deepens.

< Back

Tech Talk

issue
01
  • Contact Us
    Headquarters:
    47A Young Street
    Ottawa, Ontario
    K1S 3H6

    t: 613.722.0688
    f: 613.722.5297
    sales@lixar.com

    Map >
    East Coast Office:
    300-800 Windmill Road
    Dartmouth, Nova Scotia
    B3B 1L1

    t: 902.405.4443
    f: 902.405.4435
    eastcoast@lixar.com

    Map >
  • Support
    For all emergency inquiries for applications that Lixar supports for existing clients through service level agreements (SLA's), please contact us 24/7 either via

    - General Support Inquiries: 1-866-788-4239
    - Support for Existing Customers: 1-866-722-0688
    - Email: support@lixar.com

    More >
  • Lixar is a web technology services company with core competencies in design-development-support of web applications, business process automation, and system/database integration.