Welcome!

Adobe Flex Authors: Liz McMillan, RealWire News Distribution, Maureen O'Gara, Yakov Fain, Keith Swenson

Related Topics: Adobe Flex

Adobe Flex: Article

Developing Adobe Flex Rich Internet Applications with Cairngorm Microarchitecture

Using the Cairngorm Store sample application

What Cairngorm Teaches You
Cairngorm is a microarchitecture that addresses three key areas that we have always tried to provide as best-practice recommendations for our customers and partners:

  • Handling user gestures on the client
  • Encapsulating business logic and server interactions
  • Managing state on the client and representing this state to the user interface
Cairngorm offers a microarchitecture (collection of design patterns) that aids us in consistently solving these recurring design challenges.

As you read this series of articles, you will learn the following:

  • How the Front Controller and Command patterns implement a "Service to Worker" microarchitecture for listening and responding to user requests.
  • How the Business Delegate and Service Locator patterns interact in such a way that you can reuse the business logic and encapsulate it so that it establishes a clear contract between client and server-side development teams, independent of server-side technical implementations such as web services, Enterprise JavaBeans, ColdFusion components, or even RESTful architectures using XML over HTTP.
  • How the Value Object pattern from J2EE can collaborate with the Model Locator pattern first implemented in Cairngorm 0.99 to be an elegant strategy for maintaining a stateful client with a rich and cinematic user experience.
Current State of Cairngorm
Cairngorm is currently in version 0.99. It never made it to a 1.0 release because iteration::two became immersed in a trail of acquisitions, first by Macromedia and then by Adobe Systems. Furthermore, with Flex moving towards a 2.0 release of its own, the introduction of ActionScript 3.0, a number of improvements to the underlying Flex application framework, an exciting array of new services (including Flex Enterprise Services), and the evolution of the Cairngorm Committee - now comprised of a committed core of Adobe consultants and Adobe engineers, as well as numerous community members behind it - Adobe Consulting is focused on aligning a comprehensive Cairngorm 2.0 release that leverages the underlying Flex 2.0 framework.

The core Cairngorm concepts remain the same, however. Only the underlying implementation changes due to additional thought leadership and best practices on how to leverage Flex 2.0 features such as Flex Data Services and Flex RPC Services within a Cairngorm application. For those working with Flex 2.0 in Labs, we will also make available regular alpha releases of Cairngorm 2.0.

Note: In the final article of this series, I explore the criteria you can follow to decide when to use Cairngorm - and when not to use it. We do not advocate for a second that Cairngorm is the only way to build Rich Internet Applications. Nor do we even suggest that our best practices are the only best practices. In fact, others may promote best practices that seem to contradict what Cairngorm suggests.

All we ask is that you first try to understand the problems that Cairngorm tries to solve before preemptively solving them with Cairngorm. If you are learning Flex for the first time and consequentially building one of your first Rich Internet Applications, I strongly suggest that you become comfortable with the myriad of new tools and techniques that the technology and platform offer you before complicating your learning curve with Cairngorm.

This is not to say that Cairngorm is complex. On the contrary, it is important that you be confident and comfortable building simple RIAs that do not require the benefits of a technical architecture such as Cairngorm before taking advantage of the benefits that Cairngorm prescribes.

Future parts of this series will ensure that both seasoned and novice Flex developers understand the RIA challenges that created the problems for Cairngorm to solve. We want to explain as clearly as we can, and with detailed code-level examples, the elegant way in which Cairngorm can help you solve them.

Where to Go from Here
The aim of this article was to introduce you to the Cairngorm framework by clarifying the ambiguity around the definition and usage of frameworks, why you might use a framework, and the origins and the future of the Cairngorm framework.

Cairngorm is an architectural framework that provides a suggested implementation of a technical architecture upon which you can build your own, more complex, application-specific architectures.

By basing your application on the Cairngorm architecture, however, there are some generic and fundamental design challenges that you won't have to solve by yourself while leveraging the benefits inside Flex, such as how to handle user gestures in an elegant fashion, how to handle server interaction and business logic in an elegant and scalable fashion, and how best to manage state on a rich and immersive client application.

I gave a brief overview of the engineering discipline of software design patterns and how iteration::two borrowed those that were useful to us as J2EE developers, and which are still useful for our RIA development. Having an aerial view of the technical architecture usually helps developers identify recurring collaborations of design patterns. The concept that such collaborations, known as microarchitectures, exist is the foundation of the Cairngorm framework.

When consulting, I often say that the difference between theory and practice is that, in theory, there's no difference between theory and practice. I depart from the discussion of context and background of design patterns and microarchitecture, and instead present Cairngorm in terms of providing four key benefits:

  • Maintaining state on the client
  • Architecting the user experience
  • Implementing feature-driven development
  • Invoking server-side services
You'll get a hands-on feel for the ways we leverage the Cairngorm framework in application development, the problems that Cairngorm solves, and the ease with which you can consistently deliver highly scalable, maintainable, and robust Rich Internet Applications with Flex.

Introducing the Cairngorm Store
The Flex Store application showcases the features of the Flex application framework. It demonstrates how to use various layout containers, navigator containers, controls, effects, data binding, the Drag-and-Drop manager, form validation, and the History manager. Furthermore, Flex Store articulates the component-development model of Flex, showing how to create loosely coupled components that integrate through an event-driven architecture. The Flex Store application is an excellent way to become familiar with declarative layout using MXML and business logic development using ActionScript.

With the Cairngorm Store, I take this familiar application and completely rebuild it as an enterprise rich Internet application - an application that is rapid, scalable, and maintainable - through Cairngorm.

The Cairngorm Store borders on the complexity of a rich Internet application that would benefit from a Cairngorm architecture. I demonstrate this tipping point by showing how, within the rearchitected Cairngorm application, you can add new functionality easily, more predictably, and with significantly less development risk than if you were to attempt to add functionality to a non-Cairngorm code base.

The Cairngorm Store: Four Key Challenges
Instead of an academic discussion of design patterns we selected for Cairngorm, I will explain the common high-level challenges that often occur when developing rich Internet applications and how to achieve these solutions with a Cairngorm development process. By describing the development process, I also explain the various constituent design patterns used in the Cairngorm framework.

A good technical architect first sees application development as a solution to a business problem, then as a system that realizes this solution, then as a technical architecture for the custom software in the system, and finally as the detailed class-level implementation of that technical architecture.

The approach taken here in Cairngorm and Cairngorm Store gives you clarity from 35,000 feet before a deep dive and race along the terrain at the code level.

From a high level, there are four key challenges that the Adobe Consulting team faces, whether building mortgage calculators, retirement planners, online banks, single-screen checkouts, full e-commerce applications, or interactive maps. These challenges are as follows:

  • Keeping state on the client
  • Architecting the view
  • Driving feature-driven development
  • Invoking server-side services
The challenges and requirements for the Cairngorm Store are no different.

The client presents the products to sell to the customer, the shopping cart remembers what the user purchased, and the user must complete multipage application forms during the checkout process. Throughout this entire process, your application must maintain state on the client.

The single-screen user experience has a number of different on-screen components. It has both graphical and list-based views of the products for sale, detailed product information, a shopping cart that the user can add to or drag products to, and a series of forms that the user must fill in to fulfil his or her order. You must architect the view.

There are a number of features that users demand in the application. The users must be able to do the following:

  • View all products and get detailed information for any selected product
  • Add products to, or remove products from, their shopping cart
  • Purchase products in their cart
  • Proceed to and complete a checkout process.
These features drive your development.

Finally, the products that the application sells change as inventory changes. Your application must fetch product information from a server-side infrastructure capable of pulling products from an inventory database. Furthermore, when customers place orders, your application must persist the orders in enterprise systems by committing these orders to a database or a system such as SAP. Your application must integrate with and invoke server-side services.

As you can see, the Cairngorm Store - though unique in its business domain, product selection, and look and feel - is just like any other rich Internet application when studying it against the four key challenges.

In this article, I take a look at the first of these four key challenges: keeping state on the client.


More Stories By Steven Webster

Steven Webster is the practice director for Rich Internet Applications at Adobe. Previously, he was the technical director at iteration::two, a world-leading Rich Internet Application consultancy based in Edinburgh, Scotland. Webster is the author of Reality J2EE: Architecting for Flash MX and coauthored ActionScript 2.0 Design Patterns for Rich Internet Applications (ActionScript 2.0 Dictionary) and Developing Rich Clients with Macromedia Flex with Alistair McLeod. Steven speaks regularly at conferences and user group meetings on technical and business aspects of RIAs. Steven is the core contributor to the open-source Cairngorm project, a microarchitecture for RIAs based on J2EE patterns which was innovated by iteration::two over a number of Flash and Flex RIA developments.

Comments (2) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
Sys-Con Italy News Desk 04/04/06 10:44:53 AM EDT

This series presents an open-source architectural framework to Flex developers called Cairngorm. In this series I explain the thought leadership behind Cairngorm, the design challenges that Adobe feels Cairngorm addresses best, and the projects for which Cairngorm is an appropriate skeleton for development.

SYS-CON India News Desk 04/03/06 05:58:01 PM EDT

This series presents an open-source architectural framework to Flex developers called Cairngorm. In this series I explain the thought leadership behind Cairngorm, the design challenges that Adobe feels Cairngorm addresses best, and the projects for which Cairngorm is an appropriate skeleton for development.