{"id":184,"date":"2008-01-10T16:36:52","date_gmt":"2008-01-11T00:36:52","guid":{"rendered":"http:\/\/www.ericfeminella.com\/blog\/2008\/01\/10\/quick-tip-cairngorm-best-practice\/"},"modified":"2012-03-04T23:32:13","modified_gmt":"2012-03-05T04:32:13","slug":"quick-tip-cairngorm-best-practice","status":"publish","type":"post","link":"https:\/\/www.ericfeminella.com\/blog\/2008\/01\/10\/quick-tip-cairngorm-best-practice\/","title":{"rendered":"Quick Tip: Cairngorm Best Practice"},"content":{"rendered":"<p>When developing Flex applications in Adobe Cairngorm it is quite common to define all event constants as follows:<\/p>\n<pre lang=\"actionscript\">\r\npublic static const LOGIN_EVENT:String = \"LoginEvent\";<\/pre>\n<p>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. <\/p>\n<p>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.<\/p>\n<p>As a best practice you should assign the Event type a value which is identical to the Event&#8217;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:<\/p>\n<pre lang=\"actionscript\">\r\n\r\npackage com.domain.events\r\n{\r\nimport com.adobe.cairngorm.events.CairngormEvent;\r\n\r\npublic class LoginEvent extends CairngormEvent\r\n{    \r\n   public static const LOGIN_EVENT:String=\"com.domain.events.LoginEvent\";\r\n\r\n   public function LoginEvent()\r\n   {\r\n       super ( LOGIN_EVENT );\r\n    }\r\n  }\r\n}<\/pre>\n<p>It&#8217;s always better to be safe than sorry.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When developing Flex applications in Adobe Cairngorm it is quite common to define all event constants as follows: public static const LOGIN_EVENT:String = &#8220;LoginEvent&#8221;; 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&#8230; <a class=\"read-more\" href=\"https:\/\/www.ericfeminella.com\/blog\/2008\/01\/10\/quick-tip-cairngorm-best-practice\/\">Continue Reading<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[44],"tags":[],"class_list":["post-184","post","type-post","status-publish","format-standard","hentry","category-code-review"],"jetpack_publicize_connections":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/posts\/184","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/comments?post=184"}],"version-history":[{"count":0,"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/posts\/184\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/media?parent=184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/categories?post=184"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/tags?post=184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}