Why I think you shouldn’t use Cairngorm

| 30 Comments

I know what you must be thinking – Steven Webster is suggesting I shouldn’t use Cairngorm ? Well no, not exactly. However, the rapid adoption of the Flex 2 platform that we are currently enjoying has seen us enjoy a tremendous number of new developers to the Flex platform, many of whom are trying to absorb as much information they can in as short a time as possible. When you first become aware of the tremendous opportunities for solution development with Flex, it’s no surprise that you want to ascend the adoption curve as quickly as possible. However, there’s no short-cut to experience, and that’s the topic I want to call out here. If you’re new to Flex 2 or Cairngorm, then I’d love for you to read on a little…

So let me try and highlight some of the reasons I think you shouldn’t use Cairngorm. If this is you, I’m simply asking that you put a little space between where you were before you downloaded Flex, and where you will get to with Flex before you start building applications. That space is where all the invaluable lessons will be learned, that will serve you well in the very near future.

REASON ONE: I’ve never built an RIA of my own without Cairngorm. Not even a mini-one.

I guess this signifies your place on the learning curve; most first-time Flex developers will typically try and learn their way through the framework by building a number of small applications that test their understanding of Flex concepts.

So you’ll perhaps build some applications that just create a user-interface with containers and controls. Then you’ll maybe see if you can create a dynamic user-interface, by calling a web-service, an HTTP service or maybe even some Java business logic you have, and see if you can bind those results (you’re learning data-binding now) to a Data Grid, or other such component.

You might then try and make your application able to update some back-end persistence tier; so now you’re going to write a Java class, or a CFC in Coldfusion, or some PHP using AMFPHP, or maybe even just expose some C# code as a web-service, and see if you can’t invoke some of that server-side business logic to create, update or delete something in a database.

This is a milestone Flex accomplishment.

Next, you’re probably going to write some applications that test your understanding of styling, of states, of effects, and all manner of other Flex features – learning how to write inline ActionScript in an MXML class and invoke those inline methods in click-handlers, or upon creationComplete. You’ll then start extracting some of that ActionScript that’s inline into external classes, and flipping seamlessly between the world of MXML and ActionScript.

You don’t need Cairngorm for any of these applications you’re building above. And more importantly, if the experience of building these kind of applications isn’t one that you share, then you’d be a number of standard deviations to the left of the majority who are building applications with Cairngorm.

So go and build some sample applications, and just get used to working with Flex. Once you’ve done that, go and read the 6-part article series, and see how many of the challenges we discuss, resonate with you in your own development.

REASON TWO: You’ve seen an application built in Flex 2 and Cairngorm 2, and you want to use that as the starting point for your application. Even though REASON ONE above still applies.

The aim of the sample applications that we have released built upon Cairngorm, is to exemplify some of the best-practices when building Cairngorm applications, or to give people something they can pick apart to better understand Cairngorm.

However, these applications are not intended as the starting point for your applications – there are very few customers out there who only have 16 products that they wish to sell, and are therefore candidates for a quick rebrand of Cairngorm Store !

When you’re ready for Cairngorm, I’m going to ask that you take your first step with the Cairngorm challenge at the end of this blog entry. If you complete the Cairngorm challenge, then you’re ready to build more complicated applications with Cairngorm. If you can’t complete the Cairngorm challenge; take a few steps back and re-assess where you are in your Flex learning. Cairngorm will still be there when you’re done.

REASON THREE: Your application has only one or two user-gestures to react to.

So what exactly do I mean here ? I’m trying to measure the complexity of your application – how many different things can the user do with your application, that merit some computation being performed on the client or server. Viewing all products in a catalogue is a use-case. Adding a product to a basket is a use-case. Deleting a product from a basket is another use-case. Taking the basket to the checkout is another use-case. Checking out is another use-case. Ad infinitum. If your application has several use-cases, then the organisation that Cairngorm will bring to your source-code becomes valuable.

If however your application has one or two different views, and a few buttons/gestures that the user can make – then you can probably accomplish the application you are building without Cairngorm. Remember – the team behind Cairngorm are also huge advocates of agile software development, and the doctrines of simplicity that pervade agile thinking. Sometimes the simplest thing that could possibly work, is not to use Cairngorm. Or to paraphrase someone smarter than me, “…the best solution is not when there is nothing left to add, but when there is nothing left to take away…”.

REASON FOUR: You are the only person developing your RIA. Ever.

Many of the benefits we advocate from Cairngorm are from the predictablility, maintainability and scalability of the code-base, when it is organised with “Cairngorm thinking”. It becomes much much easier for developer D to contribute to a codebase that developers A, B and C have been working on, and to contribute to the codebase without making it more brittle to change. Or to quote another agile ambition – it can enable the idea of “collective code ownership”.

If you are the only person working on your application, that’s a good time to take a sanity check on whether Cairngorm is necessary. REASON THREE is important here – if you are the sole developer on an RIA that will have 20-30 use-cases, yes, you’ll benefit in the long term from Cairngorm. But at least use this sole-developer case as a sanity check.

REASON FIVE: You’ve found a bug in Cairngorm.

If you find a bug in Cairngorm, there’s a really good chance it’s too early for you to be using it in mission critical projects. I state this with confidence, because many years ago I was a C developer who kept finding bugs in Kernighan and Ritchie’s C compiler. Every day, I’d find something wrong with the compiler – in fact, come to think of it, I think I was responsible for finding some real clangers in the Pascal compiler on SunOS as well, back in the day.

Well, I say bugs … more often than not (in fact, come to think of it I don’t think I’ve ever successfully filed a bug against a compiler) they turned out not to be bugs. But they almost were … had it not been for the mistake that *I* had made! In fairness, I think Ali found a bug in the Java compiler once, but then he also refused to allow iteration::two to accept a tax refund from Inland Revenue, because he found a flaw in their calculations when we were subjected to a routine VAT inspection. It takes a special kind of pedant to find bugs in compilers, and flaws in Inland Revenue VAT calculations. Hope that this isn’t you.

Seriously; I don’t want to suggest there haven’t been bugs in Cairngorm, and when we’ve been through early betas, like any other software products, we’ve allowed the occasional bug to slip through. However, the Cairngorm releases that we make publically available, compiled as SWCs … we use those a lot. We eat our own dogfood. There are a lot of folks in the community using them, and if you can’t get the basic login sample that we ship to work then I’ll hazard a guess that it’s a flaw in your system setup, not a bug in Cairngorm.

If you’re getting frustrated that you’ve found a bug in Cairngorm, and you don’t know what the error message means – there’s a pretty good chance that a little bit more time spent up at REASON ONE, writing some more sample applications and experiencing compiler errors while you take your baby-steps, will help you steam past the configuration problems you’re probably experiencing with your particular Cairngorm sample application.

CAIRNGORM CHALLENGE

So here’s the Cairngorm challenge. The rite of passage for Flex developers everywhere. Open Flex Builder, and create a new Flex project. Import the cairngorm SWC – that’s right, not the source code, import the SWC.

Now, write yourself a simple Cairngorm application, that displays a datagrid, calls a publically available web-service somewhere, and then renders the results in the data grid.

Here’s a clue – you’re going to register one event with the controller, you’re going to write one command class to get the results, and to update the model locator when the results come in, you’re going to create a business delegate class for your command to invoke the web service with, and you’re going to register the web service with the service locator.

Now this is way overkill for calling a webservice to populate a data grid. But if you’re ready for working with Cairngorm, the above will be HelloWorld.cpp to you (and there will be no bugs to find in the compiler)

I GET IT. I THINK I’M READY FOR CAIRNGORM.

Fantastic. First of all, it’s fantastic, because if you are here, then you’ve wrapped your head around Flex 2, you’re comfortable building little sample applications that leverage all the various features of Flex, you understand the various problems that Cairngorm is addressing – because you read about them in my 6-part article series on Devnet, and because what’s more, you’ve actually encountered or at least became self-aware of the problems that we cite as the forces for the patterns we chose for Cairngorm. Isn’t it great – that patterns are solutions to recurring problems, and you’ve actually experienced the problems first hand ? It gives you a certain empathy with the solution already.

Now that you’re ready for Cairngorm, www.adobe.com/go/cairngorm will continue to evolve with everything that you need to build scalable, maintainable, mission-critical bet-the-business applications upon Flex 2, with a little bit of our thoughts on best-practice architecture baked in.

I’ve been deliberately tongue-in-cheek in this blog-entry, but I’m motivated by a serious point; increasingly, we’re finding developers who are finding Flex 2, and within a heartbeat are then finding Cairngorm. If developers jump too quickly into Cairngorm, it can introduce frustration into a learning curve that should have been much more shallow, and much more enjoyable, and much more focussed on Flex 2.

“But we’re a strategic customer, who are betting the business on Flex 2 and we need to ensure that we’re delivering with best-practices. And we need to be live in 3 months”.

Then that’s where leadership and mentoring are infinitely more important than technology and architecture – and organisations such as Adobe Consulting can help assure you that success.

In the meantime; there’s a great deal of people like you hanging out on Flexcoders, and a greater number of people who have taken this road ahead of you, and are more than willing to give you the help you want. So find us over at www.flexcoders.org if there’s anything we can do to help.

Don’t run before you can walk. Ain’t it always the way.

30 Comments

I feel all warm and fuzzy now :-)

I'm a failure... I'll never be good.

Great to see that you provide common sense as well as a good framework.

These 'sanity checks' should definitely be part of the Cairngorm documentation and should help to keep people from feeling that if they dont use Cairngorm (or ARP) that there is something necessarily missing from their implementation.

I tend to think that when a project fits into that grey area where you can see both organisational benefits and overkill is to consider the Cairngorm way as something to refactor towards.

Start with the most simple thing that works and then if / when the change requests arrive that require a more complex implementation, Cairngorm is a great guide of how to refactor the existing implementation.

I dove into Flex head first around the time of Beta 2. I did some little experiments and then started recreating an existing AS1 app that calls lots of web services and displays (and organizes) a lot of data. It was a freaking mess. I had code scattered and strewn everywhere and figured there had to be a better way. I started looking into Cairngorm, read the 6 part article and thought 'a-ha, this is what I need'. Shortly thereafter I started over, using Cairngorm as a base and have loved it ever since. The modularization of the different pieces of code and the consistent approach to adding functionality are the real show stoppers for me.

I am still far from a Flex expert but I know good project organization when I see it, and that is what Cairngorm gives me.

This is a fantastic eye opener. Too many times I have wanted to learn everything all at once. Flex is a huge beast. I have had to hold myself back from learning Cairngorm until I get Flex to my comfort level.

Great article.

Steven,

Thank you so much for this post!

As a person who has spent the better part of the past three years selling Flex, I've seen numerous developers try and use both Flex and Cairngorm on their first application. For 99% of those times, I've seen those same developers get burned by not first understanding how to perform CRUD operation with Flex alone.

In my experience, this inevitably means that customers have a bad taste in their mouth for Flex and never use the product again. In some cases, this means that developers make recommendations to enterprise standards boards that Flex is a poor choice for RIA. Now when I encounter those folks who ask me "So what do you think of Cairngorm?" I'll be sending them here.

Thanks again,
Kevin Hoyt
Adobe Systems, Inc.

What about Reason Six: the SWFs produced by Flex are bloated. Is it possible to somehow reduce the file size to something reasonable? If not reasonable, then at least to the file size caused by using V2 components?

Finally, this post has been born.

I've been asked "Barnesy, what do you think of Cairngorm" so many times i've lost count, I do like it for its simplicity (yes i mean that) but i hate it in the hands of a new developers.

Reason: They don't understand the problems its solving and thus they whinge about it being so big or over-architected.

On the flipside, those who've used it and understand the problems being solved with it will most likely be motivated to make their own or cherry pick it (which it then becomes a methodology heh).

Cairngorm is an idea, not a religion hehe.

(nice post Steve)

Is it just me, or does anyone else think 'Cairngorm' should be called something else? Reminds me of Cairns. Ew!

caingorm... is it the new flash? ... time to go finish the "6-part article series" i guess ;P

The most difficult part of making my first Cairngorm app work was to have Command executed after event has been dispatched. Then I found my error: I just forgot to initialize FrontController so when i fixed it, the pleasure of Cairngorm restructurability become available.

Thank you a lot for the excellent framework!

So.... let's just say I do have an issue I've found with Cairngorm 2. Where is the forum to discuss that?

Jesse Warden has continued this dialogue on his blog. For more good insights into when to use or not to use Cairngorm, see the following:
http://www.jessewarden.com/archives/2007/01/cairngorm_vs_jb.html

Hi

Thanks a lot for providing enough reasons that would surely help to decide whether to use Cairngorm or not.
I have built RIA's without Cairngorm and now feeling a bit nervous while entering this phase of development. :)

I've been reading about Cairngorm and I'm very impressed with the overall approach.

I do have some questions about Cairngorm and its applicability to some 'interesting' areas. Where is a good place to ask those questions?

For example, what if I'm trying to build a number of applications that are in different functional areas. Should I have one ServiceLocator for all of them, or perhaps a ServiceLocator superclass with the common service definitions and then extend from this for specific applications?

This is a great article Steven. I can't tell me how much the Adobe consulting team has helped me over the last 9 months of learning Flex/AS3. Thanks!

I think these blog is really useful for new comers and Excellent resource list. It´s a very interesting Blog and simple answer of many questions.Keep up the good work!
Thanks it helps me a lot

I think these blog is really useful for new comers and Excellent resource list. It´s a very interesting Blog and simple answer of many questions. Keep up the good work!

It´s a very interesting theme and a simple answer of many questions

Also I rank myself among this majority. My interest lies not in the handling of a Programiersprache separates in the ability to learn of a technology for the publication of contents on my Website. With HTML4 I can begin already very much. But I am grateful and content.

I'm a failure... I'll never be good.

Thank you a lot for the excellent framework!

Thanks for very interesting article. btw. I really enjoyed reading all of your posts. It’s interesting to read ideas, and observations from someone else’s point of view… makes you think more. So please keep up the great work. Greetings.

Nice Framework.
And thanks for giving those good ideas.

Thanks for this good ideas. Realy this is a great article.

This is a fantastic eye opener. Too many times I have wanted to learn everything all at once. Flex is a huge beast. I have had to hold myself back from learning Cairngorm until I get Flex to my comfort level.

I've recently built 2 massive applications with Flex. One a social networking site that does everything from display your connections with friends as a 3D network to sending you're information to a satellite for space casting. The other a CMS based on runtime instantiated Flex modules and drag, drop, resize Adobe Illustrator like methodology of layer manipulation.

I found many problems requiring a centralized event system and a common approach to adding functionality, issues that Cairngorm might help to relieve.

During my time building the CMS, I became aware that I would be pulled into a project built on Cairngorm. A highly complex, data intensive, multi-multi-view technician scheduling application.

So I began to learn, read up on and perform many controlled experiments with Cairngorm. I got it right away, I understood the goals of decoupling classes, having a centralized location for data, services and command registration.

Now I'm working on the project built with Cairngorm. I've looked over the application and familiarized my self with it's deep and intricate aspects. Everything I've read, seen, experimented with and experienced thus far tells my that my predecessor knew what he was doing and followed the Cairngorm patterns and framework exactly.

This is THEE perfect project for Cairngorm.

HOWEVER --- Working on this project SUCKS!!!!

Writing four classes, maybe 50+ lines of code(all cutting and pasting considered) to do what could be done in one class in about 10 lines of code is OVERKILL for any sized application.

Storing class that all work on the same event chain in four different folders is SLOPPY and provides for a very awkward work flow.

DON'T GET ME WRONG!!! I think you guys have made a great attempt here, AND... I have not as of today written and worked to widely distribute any patters/frameworks for Flex or any other language.

But I don't think you're done here, in fact, I don't even want to hear the word "Cairngorm" again until there is a version that more harmoniously blends "Productivity" with scalability and organization.

Please understand that I realize that these are my views and that they are not widely shared, but they remain my views, none the less.

I was just wondering when I could expect to see my post?

Cairngorn is nice, but imo cairngorm can make small webapplications way more complex than nessecary. Most web applications that only display data and such should i.m.o. not use cairngorm at all. Ive seen (smaller) applications that could have been built with 30% of the code and would have been way more mintainable without cairngorm.... None the less, its a great framework for the big apps. More important than knowing how to use it, is when to use it and when not.

nice framework, for productivity use codegeneration

Leave a comment

About this Entry

This page contains a single entry by Steven Webster published on August 21, 2006 1:38 PM.

Cairngorm Documentation - Tell us what you want was the previous entry in this blog.

Future plans for Cairngorm with Flex, Apollo and Flash Lite at MAX2006 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.