{"id":21,"date":"2008-07-03T14:45:55","date_gmt":"2008-07-03T21:45:55","guid":{"rendered":"http:\/\/www.nayansavla.com\/blog\/?p=21"},"modified":"2008-07-03T14:45:55","modified_gmt":"2008-07-03T21:45:55","slug":"advantage-of-using-static-classes-for-constants","status":"publish","type":"post","link":"https:\/\/www.nayansavla.com\/blog\/?p=21","title":{"rendered":"Advantage of using Static classes for constants"},"content":{"rendered":"<p>Static classes for defining constants, wait what?????. You might have come across classes like StageDisplayState in flash.display package and it doesn&#8217;t contain any useful methods except for constants which are used for setting the state of stage. This is not exactly a static class but if you remove all the methods it would be one.\u00a0<\/p>\n<p>Why do we need this class when we can set the stage property like this in AS 2,<\/p>\n<p>Stage[&#8220;displayState&#8221;] = &#8220;fullScreen&#8221;;<\/p>\n<p>where as in AS 3\/Flex its wise to use something like,<\/p>\n<p>Application.<span class=\"me1\">application<\/span>.<span class=\"kw3\">stage<\/span>.<span class=\"me1\">displayState<\/span>\u00a0= StageDisplayState.<span class=\"me1\">FULL_SCREEN<\/span>;<\/p>\n<p>It might seem unnecessary to create an extra class to define variables but its helpful.\u00a0<\/p>\n<ul>\n<li>A programmer might decide to change the string instead of fullScreen it will be now FullScreen, dumb but it can happen. If it does happen then there won&#8217;t be any errors at compile time but you might get run time errors.<\/li>\n<li>By same argument as above, if we decide to change\u00a0StageDisplayState.<span class=\"me1\">FULL_SCREEN to\u00a0StageDisplayState.<span class=\"me1\">FULLSCREEN we will get a compile time error and we can fix it.<\/span><\/span><\/li>\n<\/ul>\n<div>So its mainly to fix problems during compile time rather than run time the above method is useful. Hope it makes sense. I should probably come up with a more concrete example i suppose.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Static classes for defining constants, wait what?????. You might have come across classes like StageDisplayState in flash.display package and it doesn&#8217;t contain any useful methods except for constants which are used for setting the state of stage. This is not exactly a static class but if you remove all the methods it would be one.\u00a0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-21","post","type-post","status-publish","format-standard","hentry","category-actionscript"],"_links":{"self":[{"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/21","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=21"}],"version-history":[{"count":0,"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/21\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=21"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=21"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=21"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}