<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Singletons and Event Arbiters</title>
	<atom:link href="http://www.clientcide.com/best-practices/singletons-and-event-arbiters/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.clientcide.com/best-practices/singletons-and-event-arbiters/</link>
	<description>Making stuff work on the other side of the request.</description>
	<lastBuildDate>Thu, 12 Jan 2012 20:00:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Aaron N.</title>
		<link>http://www.clientcide.com/best-practices/singletons-and-event-arbiters/comment-page-1/#comment-32353</link>
		<dc:creator>Aaron N.</dc:creator>
		<pubDate>Mon, 13 Jul 2009 16:01:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.clientcide.com/?p=944#comment-32353</guid>
		<description>@Kris very clever!</description>
		<content:encoded><![CDATA[<p>@Kris very clever!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kris Wallsmith</title>
		<link>http://www.clientcide.com/best-practices/singletons-and-event-arbiters/comment-page-1/#comment-32352</link>
		<dc:creator>Kris Wallsmith</dc:creator>
		<pubDate>Mon, 13 Jul 2009 04:14:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.clientcide.com/?p=944#comment-32352</guid>
		<description>I&#039;ve been using Class.Occlude and occluding to document.body when I need a singleton. Works like a charm.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve been using Class.Occlude and occluding to document.body when I need a singleton. Works like a charm.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron N.</title>
		<link>http://www.clientcide.com/best-practices/singletons-and-event-arbiters/comment-page-1/#comment-32350</link>
		<dc:creator>Aaron N.</dc:creator>
		<pubDate>Thu, 02 Jul 2009 20:48:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.clientcide.com/?p=944#comment-32350</guid>
		<description>You have the $lambda stuff correct, yes.</description>
		<content:encoded><![CDATA[<p>You have the $lambda stuff correct, yes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pete Duncanson</title>
		<link>http://www.clientcide.com/best-practices/singletons-and-event-arbiters/comment-page-1/#comment-32349</link>
		<dc:creator>Pete Duncanson</dc:creator>
		<pubDate>Thu, 02 Jul 2009 13:22:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.clientcide.com/?p=944#comment-32349</guid>
		<description>@Andy - you could do it in JS but you have to use a function to return the value. You could do it just as a variable but an mistyped variable can return null which might still get through your code, calling a non-existant function via a typo though throw an error.

var MyEventNames = {
  login = function() { return &quot;login&quot;; },
  logout = function() { return &quot;logout&quot;; } )
}

mySite.fireEvent( myEventNames.login() );

I&#039;m not sure if you can do the same using the $lambda function guess you could as thats what its for which would make it more readable but I&#039;ve not used lambda much yet so could not comment but I guess it would look like this:

var MyEventNames = {
  login = $lambda( &quot;login&quot; ),
  logout = $lambda( &quot;logout&quot; )
}

@ anyone - Is the $lambda stuff right?</description>
		<content:encoded><![CDATA[<p>@Andy &#8211; you could do it in JS but you have to use a function to return the value. You could do it just as a variable but an mistyped variable can return null which might still get through your code, calling a non-existant function via a typo though throw an error.</p>
<p>var MyEventNames = {<br />
  login = function() { return &#8220;login&#8221;; },<br />
  logout = function() { return &#8220;logout&#8221;; } )<br />
}</p>
<p>mySite.fireEvent( myEventNames.login() );</p>
<p>I&#8217;m not sure if you can do the same using the $lambda function guess you could as thats what its for which would make it more readable but I&#8217;ve not used lambda much yet so could not comment but I guess it would look like this:</p>
<p>var MyEventNames = {<br />
  login = $lambda( &#8220;login&#8221; ),<br />
  logout = $lambda( &#8220;logout&#8221; )<br />
}</p>
<p>@ anyone &#8211; Is the $lambda stuff right?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Benoit</title>
		<link>http://www.clientcide.com/best-practices/singletons-and-event-arbiters/comment-page-1/#comment-32346</link>
		<dc:creator>Benoit</dc:creator>
		<pubDate>Thu, 25 Jun 2009 09:37:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.clientcide.com/?p=944#comment-32346</guid>
		<description>Great way of starting up an application, I like the mootools event system over many other frameworks.

Andy, I totally agree with you, but its true javascript doesn&#039;t has defines or constants. 

Altough you could use centralized config object to handle that sort of text keys &amp; constants, what I&#039;ve done in many projects. We use a config class with getters an setters for storing app constants as other various parameters (urls, etc.). We access it ine with something like this Config.get(&#039;LoginEventName&#039;).  
Our object throws errors when calling undefined config key, so we are aware of typo mistakes.
Of course you can use the singleton pattern for this if you want.</description>
		<content:encoded><![CDATA[<p>Great way of starting up an application, I like the mootools event system over many other frameworks.</p>
<p>Andy, I totally agree with you, but its true javascript doesn&#8217;t has defines or constants. </p>
<p>Altough you could use centralized config object to handle that sort of text keys &amp; constants, what I&#8217;ve done in many projects. We use a config class with getters an setters for storing app constants as other various parameters (urls, etc.). We access it ine with something like this Config.get(&#8216;LoginEventName&#8217;).<br />
Our object throws errors when calling undefined config key, so we are aware of typo mistakes.<br />
Of course you can use the singleton pattern for this if you want.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron N.</title>
		<link>http://www.clientcide.com/best-practices/singletons-and-event-arbiters/comment-page-1/#comment-32344</link>
		<dc:creator>Aaron N.</dc:creator>
		<pubDate>Wed, 24 Jun 2009 23:21:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.clientcide.com/?p=944#comment-32344</guid>
		<description>Ah, well, JavaScript just doesn&#039;t work this way. I&#039;m not going to go into details here (it would be a long comment, for sure), but this kind of #define functionality just doesn&#039;t exist for JavaScript (in large part because it doesn&#039;t have a compiler - at least not in the sense that C/C++ does).</description>
		<content:encoded><![CDATA[<p>Ah, well, JavaScript just doesn&#8217;t work this way. I&#8217;m not going to go into details here (it would be a long comment, for sure), but this kind of #define functionality just doesn&#8217;t exist for JavaScript (in large part because it doesn&#8217;t have a compiler &#8211; at least not in the sense that C/C++ does).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://www.clientcide.com/best-practices/singletons-and-event-arbiters/comment-page-1/#comment-32343</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Wed, 24 Jun 2009 22:54:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.clientcide.com/?p=944#comment-32343</guid>
		<description>Only that whenever you have multiple uses of the same string somewhere, then it becomes easy to misspell on of them, of if for some reason you want to change the string due to change in functionality that would require a rename, it means you can just change it in one place, instead of multiple places. If you added a new page to your website, and typed &#039;logn&#039; instead, how long would it take to notice find the issue?
 In C/C++, if you misspelled the #define you would get a compile time error, which means that the error would be caught much earlier ( and cheaper).  One way of thinking about it is this. Say you had an event called &#039;login&#039; that was used in 7 different files, and multiple times in some files. When you add a new openID login as well,you decide to rename the old &#039;login&#039; event to &#039;loginPassword&#039;. Would you prefer to change it in one place, or in multiple places ? Over the years I&#039;ve lost count the number of times things like this changed in 6 of the files, but for whatever reason the 7th file was missed.</description>
		<content:encoded><![CDATA[<p>Only that whenever you have multiple uses of the same string somewhere, then it becomes easy to misspell on of them, of if for some reason you want to change the string due to change in functionality that would require a rename, it means you can just change it in one place, instead of multiple places. If you added a new page to your website, and typed &#8216;logn&#8217; instead, how long would it take to notice find the issue?<br />
 In C/C++, if you misspelled the #define you would get a compile time error, which means that the error would be caught much earlier ( and cheaper).  One way of thinking about it is this. Say you had an event called &#8216;login&#8217; that was used in 7 different files, and multiple times in some files. When you add a new openID login as well,you decide to rename the old &#8216;login&#8217; event to &#8216;loginPassword&#8217;. Would you prefer to change it in one place, or in multiple places ? Over the years I&#8217;ve lost count the number of times things like this changed in 6 of the files, but for whatever reason the 7th file was missed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron N.</title>
		<link>http://www.clientcide.com/best-practices/singletons-and-event-arbiters/comment-page-1/#comment-32342</link>
		<dc:creator>Aaron N.</dc:creator>
		<pubDate>Wed, 24 Jun 2009 21:05:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.clientcide.com/?p=944#comment-32342</guid>
		<description>This is just an example. This isn&#039;t taken from real code I&#039;ve authored - I just tried to think of a really simple way to illustrate the point. Given that I am NOT a C/C++ guy, what is it about &#039;login&#039; that you find so distasteful?</description>
		<content:encoded><![CDATA[<p>This is just an example. This isn&#8217;t taken from real code I&#8217;ve authored &#8211; I just tried to think of a really simple way to illustrate the point. Given that I am NOT a C/C++ guy, what is it about &#8216;login&#8217; that you find so distasteful?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://www.clientcide.com/best-practices/singletons-and-event-arbiters/comment-page-1/#comment-32341</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Wed, 24 Jun 2009 20:53:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.clientcide.com/?p=944#comment-32341</guid>
		<description>I like it :). However, as an old time C/C++ guy, I&#039;ve got lots of red flags about the use of strings like &#039;login&#039; in multiple places. I would normally handle this in C by using a #define. Whats the best way of handling the same thing in Javascript ?</description>
		<content:encoded><![CDATA[<p>I like it :). However, as an old time C/C++ guy, I&#8217;ve got lots of red flags about the use of strings like &#8216;login&#8217; in multiple places. I would normally handle this in C by using a #define. Whats the best way of handling the same thing in Javascript ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: davidck</title>
		<link>http://www.clientcide.com/best-practices/singletons-and-event-arbiters/comment-page-1/#comment-32340</link>
		<dc:creator>davidck</dc:creator>
		<pubDate>Wed, 24 Jun 2009 14:16:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.clientcide.com/?p=944#comment-32340</guid>
		<description>Ooo, this is good (Event Arbiters).    I&#039;ve always been passing an instance of an object A to communicate with object B.   The fact that modularity is improved will make widgets more re-usable.</description>
		<content:encoded><![CDATA[<p>Ooo, this is good (Event Arbiters).    I&#8217;ve always been passing an instance of an object A to communicate with object B.   The fact that modularity is improved will make widgets more re-usable.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

