Filed Under (Flex, Java, RIA) by jonr on May-29-2007

This post is a follow-up to my post last week were I noted some of my initial reactions to the Cairngorm Framework.

When I look at the overview diagram of Cairngorm, I just keep hearing Eddie Vedder exasperatedly saying, “… It just doesn’t feel like we have evolved at all – in 20 years…” I will admit he might not have been talking about software (but I still love Pearl Jam – so whatever). Audio Here

After writing some code with Cairngorm I am feeling less critical. I think the structure provided by Cairngorm makes sense to some extent – at least more sense than the overview picture provided. I would still love to see a much flatter picture and resulting implementation. Either way, I figured I would throw out a few suggestions that I believe would improve the framework and the potential perception of future Java developer converts to Flex sure to check it out.

We all love patterns, and the value in them comes from the shared understanding of a given pattern. My largest hang-up with the framework is the naming of some of the components, and I am less than convinced that they all follow the patterns they are named after.

I don’t believe the “Front Controller” is true to the pattern (nor should it be). There are much better ways in Flex to accomplish the benefits articulated in the Front Controller pattern. In the Cairngorm code it is just a simple dispatch mechanism. To me, the only real value of MVC is addressing separation of concerns (SoC). This pattern needs to go by the wayside, along with the thin-client architectures we are striving to replace.

To the extent we do need some dispatch mechanism to address the SoC and a level of true decoupling, I actually think that Cairngorm falls a bit short. In the store example application, the ValidateCreditCardCommand uses the executeNextCommand function to chain commands by hard coding the next event. Certainly, this is where we could gain value from a central dispatch infrastructure. Also, the controller doesn’t really do anything except map an event to a command within the class file (there is little-to-no benefit in this).

So, in terms of trying to providing a constructive suggestion, I think Cairngorm should rename the “Front Controller” to “dispatcher,” and provide a more robust mechanism for mapping, and the chaining of multiple commands to a given event. In Flex, we really just need M & V or M-V-D (dispatch).

In addition, the Service Locator pattern could also stand to be renamed. Although, it is of far less consequence than other issues. I have had a bit of a hang-up here in explaining Cairngorm to other Java developers evaluating Flex, as it doesn’t really do any lookups per the pattern. It really just encapsulates the client side configuration for accessing remote services. So, once again the name could be considered misleading, and the Cairngorm framework should consider renaming the Service Locator.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • DZone
  • Digg
  • del.icio.us
  • Reddit
  • Facebook
  • LinkedIn

Comments:
Steven Webster on May 29th, 2007 at 4:26 am #

Jon — it’s great to follow your journey with Cairngorm, and thanks for sharing your suggestions. Remember however, that Cairngorm started life back in the days of Flash development, where things like the ServiceLocator pattern DID do lookups and manage connections, etc. As Flex performed much more heavy lifting, some of this lifting could be removed from Cairngorm.

One of the challenges/resonsibilities we face with such a prevalent and widely used framework such as Cairngorm, is backward compatibility. I think we would lose credibility if we started renaming all the patterns – at the end of the day, they very quickly become a lingua franca between developers.

The diagram you are discussing – that’s produced by the cairngormdocs.org community, and I’m sure they would welcome your contributions in helping to clarify the diagram. You’ll find them at http://www.cairngormdocs.org

Best,

Steven

barry.b on May 29th, 2007 at 6:55 am #

jon, have you recieved any comments from Steven Webster on your critique of the (esentially his) framework?

“We all love patterns, and the value in them comes from the shared understanding of a given pattern.”

which is why healthy discourse here may be of some benefit. see thru the other person’s eyes.

there’s always room for improvement somewhere so I’m sure there’s honest motavation from all concerned to do the best possible. I mean, there’s not a lot of alternatives: Cairngorm, ARP or “mess”.

jonr on May 30th, 2007 at 11:45 am #

Thanks for the comment Steven. I did NOT know that Cairngorm had such a long history. Hopefully, my comments do not come across as totally negative to Cairngorm, as I do see value in it. I do understand that backwards compatibility makes it a bit more difficult to change things.

However, I would still love to see some continue discussion in the Cairngorm community on how to best improve the framework. As I continue to code with it, I am still seeing the need for a more robust event dispatch model. For something like this, the controller could certainly remain for backwards compatibility, while adding an event model that caters more to the strengths of the Flex framework.

[...] using Flight, as I still don’t understand what value Cairngorm provides (old post 1 & 2).  That doesn’t mean I don’t believe that Flight may have value, but in learning about [...]

Post a comment
Name: 
Email: 
URL: 
Comments: