Mate vs Cairngorm

I’ve recently been comparing frameworks for Flex event handling. We are already using Mate in one of our projects. I encountered couple of problems in the usage and thought of exploring other frameworks available on the shelf.

Here are some Pros and Cons of both the frameworks:

Mate:

Pros:

  • Tag based event driven Flex framework
  • Declarative way of Event management
  • Custom Events are inherited from default Flash event; no framework code in the application
  • Uses the event-bubbling to catch the events with the EventMap without defining a bunch of wiring code

Cons:

  • State changes are to be notified explicitly to all the associated views by making use of property injection
  • Application can fail silently when you inadvertently misspell the name of the event parameter; compiler checking on tags in EventMap is missing
  • Chances of bloated MXML file since the Event dispatch logic is composed into the MXML

Cairngorm:

Pros:

  • Singleton Model – Uses Observer pattern to refresh all associated views on state change
  • Command Pattern – Clearly defines the Unit of Work. Reduces chances of bloated MXML files
  • Introduction of Business Delegate can expedite development process in projects with different teams for Client and Server implementation. Delegate can be mocked by the client development team to return dummy data.

Cons:

  • Makes codebase bit verbose
  • Custom events are inherited from CairngormEvent which introduces tight coupling between the application and the framework code

As per me, Cairngorm is more suitable for enterprise application development with huge development teams. Use of command pattern can really expedite the development process. Mate on the other hand is more suitable for small applications. However, I would expect one improvement in Mate to add compiler checking on tags in EventMap. Sometimes it really sucks when you realise there are some typos only at the runtime when you application breaks.

References:

http://www.adobe.com/devnet/flex/articles/cairngorm_pt1.html

http://mate.asfusion.com/

7 Responses to Mate vs Cairngorm

  1. John Blanco says:

    Disagreed.

    First, a “bit verbose?” :-) Just a bit? Cairngorm introduces monstrous boilerplate into the application — not just a bit.

    Second, the Singleton model is not an ideal pattern. For every component that references the Singleton, that code is no longer reusable wither (A) outside of the app (B) or within the app when the singleton reference is not desired.

    Third, Mate has the Command pattern, it’s the MethodInvoker. In fact, it’s better because you can name the methods, so you can group them better than one-class-per-Command.

    Fourth, the Delegate pattern can be used freely in Mate, too. It’s not part of Cairngorm.

    Fifth, the Event Maps can be separated into multiple MXML, reducing bloat. In fact, you can make local event maps that encapsulate a subset of your functionality (by module, view, etc.)

  2. jwopitz says:

    I have to correct a statement by the first comment about monstrous boilerplating by Cairngorm. Cairngorm gives you plenty of ropes to hang yourself. If you are binding your views to models and doign all the coupling yourself, well then that is the developer’s fault. Making use of IDataRenderer implementations and using some tricks about callbacks helps to eliminate that issue.

    Singletons are great for certain applications and poor choice for others. Development is not a “one size fits all” type of thing. You have a toolbox and you use the appropriate tools for the given tasks.

    For enterprise type applications where you have possible hundreds of User eXperiences, having 1-5 event maps is possibly not enough. Having to scroll through 1000 lines of code to modify something is not ideal.

    Anyway I wanted to share my thoughts on this. I have written two articles: 1) talking about debunking some Cairngorm myths and 2) is the a mashup of using some of the best elements from Mate, PureMVC, and Cairngorm.

    http://jwopitz.wordpress.com/2009/08/21/solution-found-cairngorm-mate-puremvc/
    http://jwopitz.wordpress.com/2009/03/11/debunking-some-cairngorm-myths/

  3. Atul Singh Parihar says:

    Really great blog i got lot of information.

    Thanks
    Atul

  4. Ocnalb Nhoj says:

    No, Cairngorm triumphs over Mate in all aspects and specially because of its Singleton Enforcer. Who ever said that the Singleton model is not ideal should go back to learning programming 101. Cairngorm’s 1 class per command is not true. You can modify this so you can have multiple commands being called in 1 class. Don’t preach if you haven’t tried it yet.

  5. jwopitz says:

    @Ocnalb Nhoj

    Not to get into a fan boy argument but you are definitely in the minority when it comes to loving Cairngorm. I think even Adobe is working on (if not already released) a newer version that addresses many of the issues people had complained about.

    Singletons are a great pattern in particular scenarios but to say it accommodates all situations, better than framework x or framework y is a quite a bold statement.

    Since working with both Cairngorm, Mate and now a spin off of SWIZ, I am definitely a fan of the general mechanisms behind how SWIZ and it’s ilk work.

    To each their own. Just remember, you are in most cases not going to be the only one working on the code.

  6. phtk says:

    I agree with Aparna on this one… aside from verbosity, there isn’t much difference between the two. To tell you the truth, I cannot find a difference in PureMVC and Cairngorm (except, there are too many ways of implementing PMVC and killing yourself)

  7. This post couldnt be more factual

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.