Thoughts on Cairngorm 3 and Application Architecture
AS3Commons, ActionScript, Cairngorm, Design Patterns, Flex, Inversion of Control, Lessons learned, Microsoft, Spring ActionScript Add commentsCairngorm 3 was recently announced by Tom Sugden and Alex Uhlmann and has now been released in beta on the Adobe Opensource site.
Don’t expect an updated version of the Cairngorm framework as you know it though. Cairngorm 3 is not aiming to be an MVC implementation, and thus moves away from what version 1 and 2 were, but now consists of a set of patterns and practices, together with a series of libraries that can help to solve common problems.
The Patterns & Practices Group at Microsoft have been promoting a similar mindset for quite some time actually: Prism – patterns & practices Composite Application Guidance for WPF
I can only encourage this decision as it is exactly how I personally think about application design and architecture, especially in Flex and AIR applications. This is also what we are trying to do with Spring ActionScript: our main goal is to provide a solid Inversion of Control container that supports multiple configuration options (XML, MXML, metadata driven component scanning, …) and promote it as a foundation to build applications (and frameworks), with or without your favorite MVC framework. Although we are working on a set of base classes that provide infrastructure for your application (under the name MVCS) with Application Events, Controllers, Abstractions for service layers, … by no means do we want to market the Spring ActionScript framework as yet another MVC implementation. (You might wonder why we are calling it MVCS then, and I’m actually wondering the same… I guess marketing and buzzwords in the opensource world are also important. All kidding aside, the name is certainly subject to change).
What’s in a name
Since this is a complete change of direction for the Cairngorm framework (which it actually no longer is) I would have expected a new name. Continuing to use Cairngorm as a name is in my opinion a bad move and will cause major confusion amongst developers and other people involved in the development process. I think the best thing for Adobe, or at least their Technical Services department, would be to let go of the name and choose a new, fresh name that moves away from the past. (Besides that, who can pronounce “Cairngorm”.)
Dependencies
I noticed that some of the modules that Cairngorm 3 provides depend on other libraries/frameworks, and in general the Parsley application framework. While Parsley is certainly a major player amongst the IoC/application frameworks, and I sincerely respect the author’s work, I don’t think this is a good decision. In case you are wondering: Yes, I would say the same thing if they decided to depend on Spring ActionScript.
The usage and choice of a concrete dependency will have consequences for the adoption and integration of the libraries that Cairngorm 3 provides. Think about it: Why would you want to pull in Parsley, perhaps only to use some of its Reflection API, if you are already running on Spring ActionScript or any other IoC container?
We, the Spring ActionScript team, have actually questioned ourselves about this in the past and have therefore decided to move all the common and reusable code from Spring ActionScript into a set of libraries known as the AS3Commons project. In that respect, I’m a bit disappointed that for instance the AS3Commons Reflect library is not used for reflection purposes, since I think it is more abstracted and unintrusive than a subset of an all-encompassing application framework. Perhaps this may be our fault of not promoting the libraries and the project enough. However, I certainly think that AS3Commons could be a wonderful project and would help to provide common libraries not only to Flex and AIR developers, but to ActionScript 3 developers in general, if it were embraced by the community.
Flex and MVC
Given that RIA technolgies are still evolving at a very fast pace, it is really remarkable to see the huge amount of MVC implementations appear. Not specifically aimed at Cairngorm (at least the previous versions), but rather at almost all MVC architectures available for Flex development, my personal feeling and experience is that the use of MVC architectures in the Adobe RIA space is almost a dogmatic thing and is not needed in most cases. The problem is that people just take an MVC framework as it is and implement it in their applications. More than often not questioning whether or not its usage is justified. Things that could easily and cleverly be solved are ripped apart across layers of the architecture, introducing levels of indirection that are in most cases not needed. The only thing they add is complexity and counter-intuitive development practices.
One of the main arguments for using an MVC framework is that the code is “easy to understand”. Of course the code will be easy to understand if you have been developing with the framework of choice for the N-th time or if you have been digging into the code for a serious amount of time, but ask a newcomer to look at the code and try to explain to you what it is actually doing… I think you’ll be surprised by the responses.
I’m not saying that the use of a particular MVC framework is de facto a bad thing, but the “religious” use and the blind adoption and implementation make a framework a killer for your application. I would encourage everyone to start their next project without an MVC framework and just use the Flex framework with a healthy knowledge of design and presentation patterns. And even if you are using an MVC implementation, think about each layer you introduce, why you need it and the pros and cons it brings.
Conclusion
It’s good to see that Adobe is rethinking their approach to RIA architecture and development practices. I also hope that they will be more open to community input and feedback than they were in the past. Although they did several attempts at engaging the community, I don’t think they really succeeded in that. If not open enough, people will just continue to fork the “framework” and provide extensions that will end up in alternative implementations anyway.
I’m looking forward to seeing how all of this evolves.
Add to Bloglines - Digg This! - del.icio.us - Stumble It! - Twit This! - Technorati links - Share on Facebook - Feedburner
Christophe Herreman is a software developer living in Belgium. He's working on high-end Flex and AIR solutions at 
October 6th, 2009 at 10:25 pm
I couldn’t agree with you more. By the way, the link from the as3-commons-reflect page that points to the Spring Actionscript site is broken (Actionscript is spelled wrong)
October 6th, 2009 at 10:27 pm
Hi Rob, thanks for the comment. We have already fixed the broken link and will deploy an update soon. Sorry for the inconvenience.
October 7th, 2009 at 10:35 am
Thanks for your thoughts on this, Christophe. Very well put!
October 7th, 2009 at 1:58 pm
I agree – frameworks are not always appropriate. On the other hand, they can be useful learning tools for people new to architecture and design patterns.
October 7th, 2009 at 3:21 pm
Could not agree with you more on the observations… Name and dependency dont seem to be well thought out… Wonder how much of that is personel preference vs a pragmatic design choice…
October 7th, 2009 at 9:31 pm
+1
The ideas of cairngorm are great, but it seems that Adobe rushed things a bit last minute. It’s like they had to come out with something (they talked on max 2008 already about Cairngorm 3 but it remained quiet). Feels to me they just took the most mature framework to build their concepts around that. I do believe Parsley is a bit more mature and feature rich than SAS but the difference is not big. I just hope the development of SAS will be going on as strong as it did lately and that adobe will remove the dependency on Parsley. There was lots of progress lately!
I personally prefer SAS above Parsley but that’s my personal preference. Parsley by the way does separate thing very well just like SAS, btw Talking about separation of concerns, I would suggest that the MVCS of SAS go in a separate swc to let people use only the IoC container. It’s a bit overhead and distracting when using your own MVC classes on top of SAS.
anyway nice article!
Arnoud
October 7th, 2009 at 11:08 pm
+1
The most important thing is to create a good component architecture. Once you do that well, then you can add a framework around it. But if you have a bad component architecture, no framework can save you.
And Adobe really has some messaging (marketing) problems with Cairngorm. Either Cairngorm is a framework, or it isn’t. They are now trying to claim that it’s a framework, but then they gave a demo of how to use Cairngorm, and they included Parsely, and then the Cairngorm 3 site is saying it’s a micro-architecture, but when you drill down to the details it’s nothing but an abstract documentation project with guidelines on how to be a good Flex programmer. Perhaps this is a reflection of the confusion within Adobe about what it is that they are trying to do.
October 10th, 2009 at 3:12 am
[...] http://www.herrodius.com/blog/216 [...]
October 13th, 2009 at 4:01 pm
Thanks for all this feedback. It will influence the progression of our Cairngorm efforts. Please note that we labelled Cairngorm 3 as beta. We want to release early and often, therefore things will change, especially when we get great feedback like this!
The dependency to Parsley isn’t our final goal. Also, note that we present 7 libraries where only 3 (all labeled as beta) are Parsley extentions. We’ve done some changes on the wiki to make this a bit clearer than before. More to come.
Thanks again for the critical feedback,
Alex
October 30th, 2009 at 12:13 am
Some good points raised.
Although, Parsley also come in modular pieces as seen here :
http://www.spicefactory.org/parsley/docs/2.1/manual/parsley-spicelib-dependencies.jpg
So you could well decide to just use the reflection functionalities alone.
February 15th, 2010 at 1:28 pm
Given the confusion in the community caused by Adobe’s release of these application support libraries (that have no relationship whatsoever to
previous releases of Cairngorm) as “Cairngorm 3″ would it make sense to
be more explicit in the Spring ActionScript documentation that Spring ActionScript’s support for “Cairngorm” is actually support for “Cairngorm 2″?
February 15th, 2010 at 2:38 pm
@Graeme: That’s a good point. I’ll create an improvement request for this in the Jira. Thanks for the input.