What is Cairngorm?
Cairngorm 2 is a lightweight framework for Enterprise RIA development in Flex 2; Cairngorm encourages the use of the best development practices on developer's side.
It takes advantage of well know Java and J2EE design patterns such as the Model View Controller, the Service Locator, the Model Locator and the View Helper.
The architecture is totally free and you can download the latest version (Cairngorm 2.2, at the moment of writing) from Adobe Labs:
http://labs.adobe.com/wiki/index.php/Cairngorm#Downloads
Why to use Cairngorm 2 in Flex development ?
Cairngorm is made up of only few Actionscript 3 classes, but in order to start implement it fast in enterprise project, you have to spend some time on it. For me this time just last a few days, spent in developing two small Flex applications.
Once you reach the top of the Cairngorm's small learning curve, you will have a complete view of the framework's functionalities and Flex as well, and the development time of enterprise application will be faster.
One of the benefits in using Cairgorm 2 is that it helps to concentrate on the application business logic.
The use of universally recognized design patterns in the enterprise application field helps enormously the insertion of new software developers into an already started project. The main reason of that is that they will have already a clear idea of the data flow because of the use of a standard and rigid architecture, very similar to Java and J2EE ones(I mean the use of Service Locator, Model Locator and the View Helper i.e.).
Moreover thanks to a coding activity that follows specific rules, the debugging phase of the application will become remarkably faster.
With the use of Cairngorm my mental approach to Flex application planning is changed, now starting from the use cases I'm able to have an idea of the final structure.
Why not to use it?
As I already said, the use of Cairngorm offers remarkable advantages, but someone seems to consider it the silver bullet of Flex development. You have to evaluate if you effectively need your application to be based on Cairngorm and not using it only to be fashionable
Steven Webster himself, tha author of Cairngorm, wrote an interesting post in his blog titles: “Why I think you shouldn’t use Cairngormâ€, with a checklist to evaluate before using it: http://weblogs.macromedia.com/swebster/archives/2006/08/why_i_think_you.cfm
On my personal experience I can say that the determining elements for using or not Cairngorm should be:
use case number,
developers number,
a plan to introduce or not new developers to the project
future implementation of new features
scalability, mantainability and reuse of the code written across different projects
Documentation and other resources
There is a community driven site with the scope of collecting Cairngorm documentation: http://www.cairngormdocs.org/
The six parts article from Steven Wester is interesting too:
http://www.adobe.com/devnet/flex/articles/cairngorm_pt1_04.html
Cairngen is an automatic Cairngorm code generator, I never used it so I cannot judge, but I think it is worth a try:
http://www.ericfeminella.com/blog/cairngen/
In the next posts about Cairngorm I'll go deep in the code and illustrate the use of Cairngorm in specific situations.