Flex Architecture, Cairngorm vs component events
When we started looking for the right framework to use at my place of work we looked at a few different frameworks that were out there. PureMVC and Cairngorm stood out as the main candidates and since we need to outsource things on occasion the natural decision was to go with due to it’s popularity and unofficial Adobe backing.
However, there are some grey areas when it comes to cairngorm that each developer has to figure out for himself such how to decide between using a cairngorm event and when to use a normal flex component event. Antoher grey area is how deep to go when binding to the ModelLocator.
Here are my general rules that I try to follow as my own “best practices”:
1. Only dispatch cairngorm events in first level components.
This should work great for simple to moderately complex applications and make event dispatching more consistent. It should also make your custom components more reusable since you don’t have to dig through them to remove references to cairngorm events that don’t exist. If you have a very complex application you can extend this second or even third level components but simply staying consistent will help in the long run.
2. Only bind to the model on first level components.
This follows the same logic as rule number one and I would also suggest that if you are binding a component to more than two properties in the ModelLocator, consider using a value object for it.
3. Events and Commands should only “work with” one type of value object.
This allows you to pass the VO you are working with as the data parameter of a cairngorm event without worrying about typing errors occurring at runtime.
Further References:
For more information on how to use cairngorm go to:
http://www.adobe.com/devnet/flex/articles/cairngorm_pt1.html
For samples of cairngorm applications and to download the framework swcs go to:
http://opensource.adobe.com/wiki/display/cairngorm/Cairngorm
Delicious
Digg
StumbleUpon
Reddit
Furl
Google
Post new comment