This is the first one of the series of article about Cairngorm Framework. This is for a beginner who is lost in bunch of classes the Cairngorm comes with. Prerequisite is that you have hand-on experience in Flex and have an idea of design patterns, atleast MVC (if you don’t have please leave a comment and based on requests received I may cover it next series). I am sure you had gone through various other resources, tutorials about Cairngorm before you reached here. Your search will end here. I will try to put it in a lay man’s language and would leave aside the tech jargon. I might not cover all the aspects/features of Cairngorm but surely at the end of this series you will be able to play around Cairngorm classes.
Cairngorm is an architectural framework which was designed to meet the need to medium to complex RIA applications. It is a skeleton which can be used as a starting point for creating your application’s architecture (for more about this, read http://www.adobe.com/devnet/flex/articles/cairngorm_pt1_02.html). For the sake of understanding, in this article we will look at re-creating the feed reader application which I created in my previous post. Please go through the post as I would be referencing the same in this post. Click here to Download Cairngorm 2.2 .
Before continuing any further lets visit definition of some commonly related (yet different) terms. “Architecture” should be looked specific to the application’s need. So if you have to design a complex application you build an architecture to wrap your application around it. “Architectural framework” (Caringorm, pureMVC, Swiz, Mate etc) can be used as a base for your application architecture. “Application framework” like Flex can be used as a solution for you application design.
There are two ways to study Cairngorm, one is to understand different parts/elements of it and see how and why they are there. Other is to see how and why it actually evolve. I will follow the latter and will start it by taking one of the design pattern it uses and will put each element one by one “in and circum-scribing” it. Cairngorm design aids in separating user gesture, business logic and state of application. It favors event driven programming model. MVC being the principle design pattern on which the Cairngorm is based we will start taking a basic MVC as a starting point and see how different design pattern plugs in and give shape to Cairngorm. Figure below shows the basic communication channels in MVC.
When user interacts with the view elements the interaction is directed to Controller. Controller, based on the interaction could either directly respond back to View to update itself (if no change in model) or can ask the model to update itself. Model after doing so will give the update information to all the registered Views. View will fetch the updated data from Model and change itself.
This is just a broad level aspect of MVC there are other communication that can happen in a MVC; even independent of user interaction, for example Model updating itself after some time interval (stock prices, clock etc). MVC in itself utilizes different design patterns like Observer and Strategy.
View is essentially where the visual elements are kept so its better to separate the View’s code from the View itself. What this means is that the view’s code/functionality, lets say it ViewHelper, will have all the functionality code to change/update the view (keep in mind that this helper won’t hold the business logic). ViewHelper is a layer of separating the View from other environmental elements. This is an interesting concept of Cairngorm, however it is deprecated in its current release, but I still favors it.
In this article you get to know about frameworks and the first
element (ViewHelper) of Cairngorm. In the next article we will cover ViewHelper in detail.
If you liked this post, please spread the word. Share and cheer!!!.
If you need more information on above post drop a comment. Your comments are valuable and helps in molding the article so do share in.
You can also read this (and more such) article at : http://blog.brupp.com