Quick Tip: Cairngorm Best Practice

Thursday, January 10th, 2008

When developing Flex applications in Adobe Cairngorm it is quite common to define all event constants as follows:

The problem with this design is that there is no way of guaranteeing the event type will not collide with an Event type in another package.

Now, I think it is only fair to say that in a good design there typically would not be two Events with the exact same name. However, when developing large scale Flex applications in which additional modules are added with each major release, not to mention the fact that there can be literally hundreds and hundreds of classes, the chances of creating an Event with the same name begins to increase.

As a best practice you should assign the Event type a value which is identical to the Event’s fully qualified class path. This will ensure there can never be a collision of Event types. An example can be seen in the following:

It’s always better to be safe than sorry.

{ 8 comments to read ... please submit one more! }


    Warning: call_user_func() expects parameter 1 to be a valid callback, function 'theme_comment' not found or invalid function name in /home/efeminella/ericfeminella.com/blog/wp-includes/class-walker-comment.php on line 180

    Warning: call_user_func() expects parameter 1 to be a valid callback, function 'theme_comment' not found or invalid function name in /home/efeminella/ericfeminella.com/blog/wp-includes/class-walker-comment.php on line 180

    Warning: call_user_func() expects parameter 1 to be a valid callback, function 'theme_comment' not found or invalid function name in /home/efeminella/ericfeminella.com/blog/wp-includes/class-walker-comment.php on line 180

    Warning: call_user_func() expects parameter 1 to be a valid callback, function 'theme_comment' not found or invalid function name in /home/efeminella/ericfeminella.com/blog/wp-includes/class-walker-comment.php on line 180

    Warning: call_user_func() expects parameter 1 to be a valid callback, function 'theme_comment' not found or invalid function name in /home/efeminella/ericfeminella.com/blog/wp-includes/class-walker-comment.php on line 180

    Warning: call_user_func() expects parameter 1 to be a valid callback, function 'theme_comment' not found or invalid function name in /home/efeminella/ericfeminella.com/blog/wp-includes/class-walker-comment.php on line 180

    Warning: call_user_func() expects parameter 1 to be a valid callback, function 'theme_comment' not found or invalid function name in /home/efeminella/ericfeminella.com/blog/wp-includes/class-walker-comment.php on line 180

    Warning: call_user_func() expects parameter 1 to be a valid callback, function 'theme_comment' not found or invalid function name in /home/efeminella/ericfeminella.com/blog/wp-includes/class-walker-comment.php on line 180

{ 0 Pingbacks/Trackbacks }