Archive for August, 2006

Why I think you shouldn’t use Cairngorm

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.

Cairngorm Documentation – Tell us what you want

Dan Harfleet has posted over on his blog about our current efforts within Adobe Consulting to revisit the content on Adobe Labs related to Cairngorm.

We’re now devoting some time and effort to increasing the level, depth and breadth of content that will help you be successful with Cairngorm – Dan is soliciting feedback from the community for what would best help them get started, and get productive with Cairngorm. So what do you need; more sample applications ? More getting started articles ? Deeper-dive articles into specific topics ?

Please check out Dan’s blog, leave him some comments or drop him a line, and we’ll be able to focus the time we spend on this to meet your needs more exactly.

Developing Cairngorm 2 and Flex 2 Applications Document

Digimmersion are a company that create stencils for Visio for creating wireframes for Flex development; I notice that they have a great little document that explains to people how to build a Flex 2 application with Cairngorm – you can find it here. For those of you learning to develop with Cairngorm, you may find value from this 30-page article.

It’s really satisfying to see that the community is now delivering these offerings around Cairngorm and Flex !