views:

5636

answers:

11
+18  Q: 

Flex MVC Frameworks

I'm currently using and enjoying using the Flex MVC framework PureMVC. I have heard some good things about Cairngorm, which is supported by Adobe and has first-to-market momentum. And there is a new player called Mate, which has a good deal of buzz.

Has anyone tried two or three of these frameworks and formed an opinion?

Thanks!

+33  A: 

Mate is my pick. The first and foremost reason is that it is completely unobtrusive. My application code has no dependencies on the framework, it is highly decoupled, reusable and testable.

One of the nicest features of Mate is the declarative configuration, essentially you wire up your application in using tags in what is called an event map -- basically a list of events that your application generates, and what actions to take when they occur. The event map gives a good overview of what your application does. Mate uses Flex' own event mechanism, it does not invent its own like most other frameworks. You can dispatch an event from anywhere in the view hierarchy and have it bubble up to the framework automatically, instead of having to have a direct line, like Cairngorms CairngormEventDispatcher or PureMVC's notification system.

Mate also uses a form of dependency injection (leveraging bindings) that makes it possible to connect your models to your views without either one knowing about the other. This is probably the most powerful feature of the framework.

In my view none of the other Flex application frameworks come anywhere near Mate. However, these are the contenders and why I consider them to be less useful:

PureMVC actively denies you many of the benefits of Flex (for example bindings and event bubbling) in order for the framework to be portable -- a doubious goal in my view. It is also over-engineered, and as invasive as they come. Every single part of your application depends on the framework. However, PureMVC isn't terrible, just not a very good fit for Flex. An alternative is FlexMVCS, an effort to make PureMVC more suitable for Flex (unfortunately there's no documentation yet, just source).

Cairngorm is a bundle of anti-patterns that lead to applications that are tightly coupled to global variables. Nuff said (but if you're interested, here are some more of my thoughts, and here too).

Swiz is a framework inspired by the Spring framework for Java and Cairngorm (trying to make up for the worst parts of the latter). It provides a dependency injection container and uses metadata to enable auto-wiring of dependencies. It is interesting, but a little bizzare in that goes to such lengths to avoid the global variables of Cairngorm by using dependency injection but then uses a global variable for central event dispatching.

Those are the ones I've tried or researched. There are a few others that I've heard about, but none that I think are widely used. Mate and Swiz were both presented at the recent 360|Flex conference, and there are videos available (the Mate folks have instructions on how to watch them)

Theo
Good analysis and generally I agree with you. It should be noted that the central dispatcher in Swiz is optional and really only needed when you have a event that many views / components require notification of, such as login, logout, etc.
cliff.meyers
Long time past, but thanks for the thoughtful answer. I was already committed to PureMVC at the time. And I found some pluses (clean separation between layers) and minuses (code quantity, testability, and the notification system). Based on your feedback and others', I just started a new project with Mate.
Rydell
I felt exactly the same when I started looking into Cairngorm. The first thing I'm told about is a ModelLocator, to keep track of models and application state? That rang some bells, especially as a Getting Started tutorial.
seanmonstar
A: 

Bear in mind that Cairngorm is THE adobe sponsored framework, and now hosted on opensource.adobe.com. Also note that it's by far the most prolific amongst developers at the moment.

If you know Cairngorm and are looking for a job, you won't go far wrong.

Neil Middleton
A: 

Cairngorm is easy to use and well documented: http://www.cairngormdocs.org/

I recommend the Cairngorm Diagram Explorer and the classic article about Cairngorm.

I was new to Flex when I learned Cairngorm but found it useful and easy to learn with the above.

Brandon
+4  A: 

@Neil Middleton - If someone hires me because "I know Cairngorm" and I accept this as a requirement, it means I have the wrong employer and/or the wrong attitude.

We use Mate since a couple of months now after initially evaluating Cairngorm. The short learning curve, the simplicity and the elegant way of staying unobtrusive makes Mate excellent for almost everything.

I agree with all the points raised by Theo but there's one more thing: Mate actually manages to force the developers learn good practices in terms of architecture whereas Cairngorm doesn't. I've interviewed a couple of Flex candidates that stated "we used Cairngorm in our projects" but, when I asked them about the reasoning, beside being enforced by the company, nobody actually understood why they should use it and how is that in their advantage.

Having a developer taking things for granted is another reason why any company should think twice before employing somebody. Personally, I like people that fight for their reasons.

I don't know how Mate starts a developer's appetite for learning patterns, perhaps it's a magic combination of many things, but I know for sure that I haven't seen this steady-happy culture around any other framework. It's almost hippie :) (or perhaps it's just Laura's voice in her screencasts - j/k ).

Emil Tamas
+1  A: 

We are currently working on a MVCS implementation in the Spring ActionScript framework. It uses the full power of the Inversion of Control container so you have centralized dependency management and are able to swap things easily. It is not very prescriptive in how you do things but provides you with a very flexible infrastructure.

If you are new to Spring ActionScript and MVCS, I have an introductory post at my blog: http://www.herrodius.com/blog/158

Christophe Herreman
+3  A: 

I've seen these kinds of discussions many many times. They usually start with WHICH Flex framework do you use. Not many people ask the question WHY do you even need to use any framework on top of Flex framework.

I'm not in favor of using any MVC framework (Cairngorm, PureMVC) in Flex code. Mate is a better candidate. At least it's simple to understand and is non intrusive. I prefer using enhanced components ala cart. We've created and open sourced a bunch of them (see clear.swc in the Clear Toolkit at http://sourceforge.net/projects/cleartoolkit/.

The first chapter of our upcoming O'Reilly book "Enterprise Development with Flex" has a detailed comparison of several Flex frameworks: http://my.safaribooksonline.com/9780596801465 .

Yakov Fain
A: 

MATE is the way to go.A framework which does what a framework should do. De-coupled architecture Simple Small foot print Efficiency

A: 

I kinda have my doubts on these MVC frameworks (Mate, Cairgnorm, etc...) with the way they implement event maps and event controllers, it reminds me too much of wxWidgets and other GUI toolkits of that sort.

However, would be really nice is if Flex or one of these MVC frameworks uses the Signal/Slots paradigm that Qt offers.

Los
A: 

I was recently looking for the same and found.

Guasax - http://www.guasax.com/guasax/web/en/index.php

Sidmitra
A: 

I recommend to use MATE for developing greats and complicated projects,like other frameworks, Mate addresses the common architectural concerns in Flex such as event handling, data binding, and asynchronous processing, but the most important goal is that it's only tag-based so it's very easy to use it in our Flex Applications.

Vadim Slutsky
+3  A: 

Check out Robotlegs.

"It provides the glue that your application needs to easily function in a decoupled way. Through the use of automated metadata based dependency injection Robotlegs removes boilerplate code in an application. By promoting loose coupling and avoiding the use of Singletons and statics in the framework Robotlegs can help you write code that is highly testable."

Vladimir Grigorov