<?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 for aKa Web Design</title>
	<atom:link href="http://www.akawebdesign.com/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.akawebdesign.com</link>
	<description>Longtime nerd. Rockstar developer.</description>
	<lastBuildDate>Mon, 20 Feb 2012 19:16:31 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>Comment on JavaScript Encapsulation by David</title>
		<link>http://www.akawebdesign.com/2011/11/25/javascript-encapsulation/#comment-688</link>
		<dc:creator>David</dc:creator>
		<pubDate>Mon, 20 Feb 2012 19:16:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.akawebdesign.com/?p=766#comment-688</guid>
		<description>Thanks, I got it:

So the real magic is here:

    return {
        name : config.name,
        age  : config.age,

	get  : function() { 
		return getPrivateValue(); },
        set  : function(newValue) { setPrivateValue(newValue); }
    };

Not in the var.... above.

Doh! thanks!! :)</description>
		<content:encoded><![CDATA[<p>Thanks, I got it:</p>
<p>So the real magic is here:</p>
<p>    return {<br />
        name : config.name,<br />
        age  : config.age,</p>
<p>	get  : function() {<br />
		return getPrivateValue(); },<br />
        set  : function(newValue) { setPrivateValue(newValue); }<br />
    };</p>
<p>Not in the var&#8230;. above.</p>
<p>Doh! thanks!! <img src='http://www.akawebdesign.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JavaScript Encapsulation by Arthur Kay</title>
		<link>http://www.akawebdesign.com/2011/11/25/javascript-encapsulation/#comment-687</link>
		<dc:creator>Arthur Kay</dc:creator>
		<pubDate>Mon, 20 Feb 2012 19:07:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.akawebdesign.com/?p=766#comment-687</guid>
		<description>In other words, David.SSN should be undefined.</description>
		<content:encoded><![CDATA[<p>In other words, David.SSN should be undefined.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JavaScript Encapsulation by Arthur Kay</title>
		<link>http://www.akawebdesign.com/2011/11/25/javascript-encapsulation/#comment-686</link>
		<dc:creator>Arthur Kay</dc:creator>
		<pubDate>Mon, 20 Feb 2012 19:04:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.akawebdesign.com/?p=766#comment-686</guid>
		<description>No... SSN is encapsulated. Using my example:

&lt;pre&gt;&lt;code&gt;
var David = Person({
    name : &#039;David&#039;,
    age  : 30,
    SSN  : &#039;123-456-7890&#039;
});
&lt;/code&gt;&lt;/pre&gt;

You can never DIRECTLY access David&#039;s SSN property. It has a get/set method, which can modify the encapsulated variable (SSN, inside the function scope). SSN is never exposed outside the scope of the Person &quot;factory&quot; method.</description>
		<content:encoded><![CDATA[<p>No&#8230; SSN is encapsulated. Using my example:</p>
<pre><code>
var David = Person({
    name : 'David',
    age  : 30,
    SSN  : '123-456-7890'
});
</code></pre>
<p>You can never DIRECTLY access David&#8217;s SSN property. It has a get/set method, which can modify the encapsulated variable (SSN, inside the function scope). SSN is never exposed outside the scope of the Person &#8220;factory&#8221; method.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JavaScript Encapsulation by David</title>
		<link>http://www.akawebdesign.com/2011/11/25/javascript-encapsulation/#comment-685</link>
		<dc:creator>David</dc:creator>
		<pubDate>Mon, 20 Feb 2012 18:59:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.akawebdesign.com/?p=766#comment-685</guid>
		<description>Thanks Arthur,

I figured that was the case. In all then would you say exposing 
var SSN = config.SSN;
thereby making it publicly accessible is confusing in an example which deals with encapsulation, especially given your example was the SSN variable.

Because Im not a Javascript guru, I was left scratching my head about it was that you ended up hiding SSN. The answer was that SSN was exposed and therefore not encapsulated.

Again, thanks for explaining (I hope Im right!! :-/  )</description>
		<content:encoded><![CDATA[<p>Thanks Arthur,</p>
<p>I figured that was the case. In all then would you say exposing<br />
var SSN = config.SSN;<br />
thereby making it publicly accessible is confusing in an example which deals with encapsulation, especially given your example was the SSN variable.</p>
<p>Because Im not a Javascript guru, I was left scratching my head about it was that you ended up hiding SSN. The answer was that SSN was exposed and therefore not encapsulated.</p>
<p>Again, thanks for explaining (I hope Im right!! :-/  )</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JavaScript Encapsulation by Arthur Kay</title>
		<link>http://www.akawebdesign.com/2011/11/25/javascript-encapsulation/#comment-684</link>
		<dc:creator>Arthur Kay</dc:creator>
		<pubDate>Mon, 20 Feb 2012 18:52:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.akawebdesign.com/?p=766#comment-684</guid>
		<description>When you create a new instance of Person, the set() method does not get called.

&lt;pre&gt;&lt;code&gt;
var David = Person({
    name : &#039;David&#039;,
    age  : 30,
    SSN  : &#039;123-456-7890&#039;
});
&lt;/code&gt;&lt;/pre&gt;

However, you can later call:

&lt;pre&gt;&lt;code&gt;
David.set(&#039;111-22-3333&#039;);
&lt;/code&gt;&lt;/pre&gt;

...which should hit your breakpoint.</description>
		<content:encoded><![CDATA[<p>When you create a new instance of Person, the set() method does not get called.</p>
<pre><code>
var David = Person({
    name : 'David',
    age  : 30,
    SSN  : '123-456-7890'
});
</code></pre>
<p>However, you can later call:</p>
<pre><code>
David.set('111-22-3333');
</code></pre>
<p>&#8230;which should hit your breakpoint.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Event-Driven Architecture by Arthur Kay</title>
		<link>http://www.akawebdesign.com/2011/03/15/event-driven-architecture/#comment-683</link>
		<dc:creator>Arthur Kay</dc:creator>
		<pubDate>Mon, 20 Feb 2012 18:49:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.akawebdesign.com/?p=622#comment-683</guid>
		<description>You&#039;re right, I could have. I was probably just being lazy...</description>
		<content:encoded><![CDATA[<p>You&#8217;re right, I could have. I was probably just being lazy&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Event-Driven Architecture by Reynald</title>
		<link>http://www.akawebdesign.com/2011/03/15/event-driven-architecture/#comment-682</link>
		<dc:creator>Reynald</dc:creator>
		<pubDate>Mon, 20 Feb 2012 13:46:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.akawebdesign.com/?p=622#comment-682</guid>
		<description>Thanks for the sample! I also found using events and subscribing to them quite useful!

One little point. I see that in your sample, your are subscribing and unsubscribing upon the destroy on the component. Instead of using &#039;on&#039; and &#039;un&#039;, couldn&#039;t you use just &#039;mon&#039; ? (it will simplify you code even further...)

My .02 cents.</description>
		<content:encoded><![CDATA[<p>Thanks for the sample! I also found using events and subscribing to them quite useful!</p>
<p>One little point. I see that in your sample, your are subscribing and unsubscribing upon the destroy on the component. Instead of using &#8216;on&#8217; and &#8216;un&#8217;, couldn&#8217;t you use just &#8216;mon&#8217; ? (it will simplify you code even further&#8230;)</p>
<p>My .02 cents.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JavaScript Encapsulation by David</title>
		<link>http://www.akawebdesign.com/2011/11/25/javascript-encapsulation/#comment-681</link>
		<dc:creator>David</dc:creator>
		<pubDate>Sun, 19 Feb 2012 01:44:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.akawebdesign.com/?p=766#comment-681</guid>
		<description>Thanks for the explanation, the trouble I have is that I dont see how:

SSN  : &#039;123-456-7890&#039;

invokes

set  : function(newValue) { setPrivateValue(newValue); }

I ran your code in chrome and put a break point on the set: function. The code did not stop at the breakpoint. Im new to Javascript.</description>
		<content:encoded><![CDATA[<p>Thanks for the explanation, the trouble I have is that I dont see how:</p>
<p>SSN  : &#8217;123-456-7890&#8242;</p>
<p>invokes</p>
<p>set  : function(newValue) { setPrivateValue(newValue); }</p>
<p>I ran your code in chrome and put a break point on the set: function. The code did not stop at the breakpoint. Im new to Javascript.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JavaScript Encapsulation by Arthur Kay</title>
		<link>http://www.akawebdesign.com/2011/11/25/javascript-encapsulation/#comment-680</link>
		<dc:creator>Arthur Kay</dc:creator>
		<pubDate>Fri, 17 Feb 2012 17:53:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.akawebdesign.com/?p=766#comment-680</guid>
		<description>David,

getPrivateValue() is invoked whenever someone calls the method Person.get()... the same idea with setPrivateValue() and Person.set().

In short, getPrivateValue() and setPrivateValue() are private methods. &lt;strong&gt;They can never directly be called by anything because they are ENCAPSULATED within the closure.&lt;/strong&gt; Person.get() invokes getPrivateValue() for us, but we can&#039;t call it directly because of the private scope. Make sense?

The Person constructor returns an object literal. That object alone has access to the variables/methods contained within the closure.

SSN is assigned to a local variable (within the closure), so the only way to get/set it&#039;s value is by calling getPrivateValue() and setPrivateValue(). If you were to override the Person.get() or Person.set() methods, we would lose our link to the data structures contained within the closure.</description>
		<content:encoded><![CDATA[<p>David,</p>
<p>getPrivateValue() is invoked whenever someone calls the method Person.get()&#8230; the same idea with setPrivateValue() and Person.set().</p>
<p>In short, getPrivateValue() and setPrivateValue() are private methods. <strong>They can never directly be called by anything because they are ENCAPSULATED within the closure.</strong> Person.get() invokes getPrivateValue() for us, but we can&#8217;t call it directly because of the private scope. Make sense?</p>
<p>The Person constructor returns an object literal. That object alone has access to the variables/methods contained within the closure.</p>
<p>SSN is assigned to a local variable (within the closure), so the only way to get/set it&#8217;s value is by calling getPrivateValue() and setPrivateValue(). If you were to override the Person.get() or Person.set() methods, we would lose our link to the data structures contained within the closure.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JavaScript Encapsulation by David</title>
		<link>http://www.akawebdesign.com/2011/11/25/javascript-encapsulation/#comment-679</link>
		<dc:creator>David</dc:creator>
		<pubDate>Thu, 16 Feb 2012 19:42:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.akawebdesign.com/?p=766#comment-679</guid>
		<description>Ive read the code a few times. I dont see how you are using:

        get  : function() { return getPrivateValue(); },
        set  : function(newValue) { setPrivateValue(newValue); }

and how you are using:

   function getPrivateValue() { return SSN; }
    function setPrivateValue(value) { SSN = value; }

What is calling these methods??

SSN is assigned in the constructor, but I dont see what links it to those methods/functions</description>
		<content:encoded><![CDATA[<p>Ive read the code a few times. I dont see how you are using:</p>
<p>        get  : function() { return getPrivateValue(); },<br />
        set  : function(newValue) { setPrivateValue(newValue); }</p>
<p>and how you are using:</p>
<p>   function getPrivateValue() { return SSN; }<br />
    function setPrivateValue(value) { SSN = value; }</p>
<p>What is calling these methods??</p>
<p>SSN is assigned in the constructor, but I dont see what links it to those methods/functions</p>
]]></content:encoded>
	</item>
</channel>
</rss>

