<?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: I see your privates: How objects of the same class can share private variables in AS3</title>
	<atom:link href="http://joshblog.net/2008/10/08/actionscript-3-private-variables-are-not-private/feed/" rel="self" type="application/rss+xml" />
	<link>http://joshblog.net/2008/10/08/actionscript-3-private-variables-are-not-private/</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Mon, 21 May 2012 15:06:03 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Paul</title>
		<link>http://joshblog.net/2008/10/08/actionscript-3-private-variables-are-not-private/#comment-1091</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Sun, 26 Oct 2008 08:27:18 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=352#comment-1091</guid>
		<description>A private member variable may be accessed if a method is written for it, but it can not be accessed if no method exists for it. In other words:

var oJane:Person = new Person(&#039;Jane&#039;, &#039;Jane has a secret&#039;);

// will error:
// trace(&#039;Jane is secure from direct member access: &#039; + oJane._secret);

// will succeed:
trace(&#039;Jane is not secure by method and design: &#039; + oJane.peekIntoDiary(this));</description>
		<content:encoded><![CDATA[<p>A private member variable may be accessed if a method is written for it, but it can not be accessed if no method exists for it. In other words:</p>
<p>var oJane:Person = new Person(&#8216;Jane&#8217;, &#8216;Jane has a secret&#8217;);</p>
<p>// will error:<br />
// trace(&#8216;Jane is secure from direct member access: &#8216; + oJane._secret);</p>
<p>// will succeed:<br />
trace(&#8216;Jane is not secure by method and design: &#8216; + oJane.peekIntoDiary(this));</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tink</title>
		<link>http://joshblog.net/2008/10/08/actionscript-3-private-variables-are-not-private/#comment-1090</link>
		<dc:creator>Tink</dc:creator>
		<pubDate>Thu, 09 Oct 2008 12:29:18 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=352#comment-1090</guid>
		<description>Kinda sneaky ;)

Thanks</description>
		<content:encoded><![CDATA[<p>Kinda sneaky <img src='http://joshblog.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://joshblog.net/2008/10/08/actionscript-3-private-variables-are-not-private/#comment-1089</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Thu, 09 Oct 2008 03:05:07 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=352#comment-1089</guid>
		<description>The place I see this used most in Java is in implementing a .equals() method.  Usually classes which provide their own .equals method will just go through and compare all the member properties of two instances.  It would be awkward to implement without access to the other object&#039;s private members.

That being said, I agree with the general sentiment that the behavior is non-obvious at first.</description>
		<content:encoded><![CDATA[<p>The place I see this used most in Java is in implementing a .equals() method.  Usually classes which provide their own .equals method will just go through and compare all the member properties of two instances.  It would be awkward to implement without access to the other object&#8217;s private members.</p>
<p>That being said, I agree with the general sentiment that the behavior is non-obvious at first.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Darren</title>
		<link>http://joshblog.net/2008/10/08/actionscript-3-private-variables-are-not-private/#comment-1088</link>
		<dc:creator>Darren</dc:creator>
		<pubDate>Thu, 09 Oct 2008 01:11:08 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=352#comment-1088</guid>
		<description>Josh, maybe the question is really what use-cases can you think of where this would be useful? The point of private variables is not to stop bad objects seeing/changing something they shouldn&#039;t, it&#039;s to stop bad coders seeing/changing something they shouldn&#039;t. As Olivier alluded to above, if you have access to the class to put in your peekIntoDiary function, you could just as easily put in a getter function or make the variable public.</description>
		<content:encoded><![CDATA[<p>Josh, maybe the question is really what use-cases can you think of where this would be useful? The point of private variables is not to stop bad objects seeing/changing something they shouldn&#8217;t, it&#8217;s to stop bad coders seeing/changing something they shouldn&#8217;t. As Olivier alluded to above, if you have access to the class to put in your peekIntoDiary function, you could just as easily put in a getter function or make the variable public.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Olivier Allouch</title>
		<link>http://joshblog.net/2008/10/08/actionscript-3-private-variables-are-not-private/#comment-1087</link>
		<dc:creator>Olivier Allouch</dc:creator>
		<pubDate>Wed, 08 Oct 2008 23:13:11 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=352#comment-1087</guid>
		<description>The tree structure is an excellent example.
And, you may not have noticed it because it&#039;s sometime not simple to notice it, especially in Java where you don&#039;t have the get/set types of functions, so no need for &quot;_&quot; before object arguments.</description>
		<content:encoded><![CDATA[<p>The tree structure is an excellent example.<br />
And, you may not have noticed it because it&#8217;s sometime not simple to notice it, especially in Java where you don&#8217;t have the get/set types of functions, so no need for &#8220;_&#8221; before object arguments.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Welsh</title>
		<link>http://joshblog.net/2008/10/08/actionscript-3-private-variables-are-not-private/#comment-1086</link>
		<dc:creator>Mike Welsh</dc:creator>
		<pubDate>Wed, 08 Oct 2008 22:18:36 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=352#comment-1086</guid>
		<description>This behavior is pretty standard across langauges, but it&#039;s definitely a surprise the first time you notice it.  I know C++ and Java operate the same way.  As others have pointed out, it makes sense and can be useful.

Another case would be for a tree or linked-list object, where you may have code to remove a node from the tree: _parent._child = null; _parent = null;

You don&#039;t see it too often, but it&#039;s definitely out there.  Maybe people are just so accustomed to making public accessor methods for their private variables, that they end up using them even in these cases? :)</description>
		<content:encoded><![CDATA[<p>This behavior is pretty standard across langauges, but it&#8217;s definitely a surprise the first time you notice it.  I know C++ and Java operate the same way.  As others have pointed out, it makes sense and can be useful.</p>
<p>Another case would be for a tree or linked-list object, where you may have code to remove a node from the tree: _parent._child = null; _parent = null;</p>
<p>You don&#8217;t see it too often, but it&#8217;s definitely out there.  Maybe people are just so accustomed to making public accessor methods for their private variables, that they end up using them even in these cases? <img src='http://joshblog.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Tynjala</title>
		<link>http://joshblog.net/2008/10/08/actionscript-3-private-variables-are-not-private/#comment-1085</link>
		<dc:creator>Josh Tynjala</dc:creator>
		<pubDate>Wed, 08 Oct 2008 20:44:59 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=352#comment-1085</guid>
		<description>I have a question for the commenters who say this isn&#039;t unexpected. If it seems logical to you, then why don&#039;t I see developers taking advantage of this behavior more often? From the moment I started learning software development in 2001 to yesterday, over seven years later, I&#039;d never seen anyone use this feature. Why not? Are there too few use-cases? Is it rare for one instance to have a reference to another instance of the same type? What is it?

It honestly seems very strange to me that I would never have encountered this in code written in any of the languages I&#039;ve used before, whether ActionScript, Java, or something else. I&#039;ve probably seen every other obscure feature of ActionScript used at least once. I&#039;ve even seen &lt;em&gt;undocumented&lt;/em&gt; features in AS2 used sometimes. Why not this one?</description>
		<content:encoded><![CDATA[<p>I have a question for the commenters who say this isn&#8217;t unexpected. If it seems logical to you, then why don&#8217;t I see developers taking advantage of this behavior more often? From the moment I started learning software development in 2001 to yesterday, over seven years later, I&#8217;d never seen anyone use this feature. Why not? Are there too few use-cases? Is it rare for one instance to have a reference to another instance of the same type? What is it?</p>
<p>It honestly seems very strange to me that I would never have encountered this in code written in any of the languages I&#8217;ve used before, whether ActionScript, Java, or something else. I&#8217;ve probably seen every other obscure feature of ActionScript used at least once. I&#8217;ve even seen <em>undocumented</em> features in AS2 used sometimes. Why not this one?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Olivier Allouch</title>
		<link>http://joshblog.net/2008/10/08/actionscript-3-private-variables-are-not-private/#comment-1084</link>
		<dc:creator>Olivier Allouch</dc:creator>
		<pubDate>Wed, 08 Oct 2008 20:25:23 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=352#comment-1084</guid>
		<description>And to be completely honest, I have to say I also was surprise when I first discovered it :)
The OOP makes us see objects as independent individuals, and we tend to forget that OOP security is to protect from coders, not objects.
We&#039;re just getting too virtual, I guess.</description>
		<content:encoded><![CDATA[<p>And to be completely honest, I have to say I also was surprise when I first discovered it <img src='http://joshblog.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
The OOP makes us see objects as independent individuals, and we tend to forget that OOP security is to protect from coders, not objects.<br />
We&#8217;re just getting too virtual, I guess.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Olivier Allouch</title>
		<link>http://joshblog.net/2008/10/08/actionscript-3-private-variables-are-not-private/#comment-1083</link>
		<dc:creator>Olivier Allouch</dc:creator>
		<pubDate>Wed, 08 Oct 2008 20:03:18 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=352#comment-1083</guid>
		<description>Actually, this behavior is completely standard and logical. Who decided this variable is private ? The guy that wrote that class. When he writes other methods of this class, he is home. If he can make this variable public, why couldn&#039;t he read it when it&#039;s private ? It&#039;s his !</description>
		<content:encoded><![CDATA[<p>Actually, this behavior is completely standard and logical. Who decided this variable is private ? The guy that wrote that class. When he writes other methods of this class, he is home. If he can make this variable public, why couldn&#8217;t he read it when it&#8217;s private ? It&#8217;s his !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Tynjala</title>
		<link>http://joshblog.net/2008/10/08/actionscript-3-private-variables-are-not-private/#comment-1082</link>
		<dc:creator>Josh Tynjala</dc:creator>
		<pubDate>Wed, 08 Oct 2008 17:57:40 +0000</pubDate>
		<guid isPermaLink="false">http://joshblog.net/?p=352#comment-1082</guid>
		<description>Thanks to the two Daniels for the interesting info. I guess I always just assumed that, using the terms the second Daniel mentioned, &lt;code&gt;private&lt;/code&gt; means object-private rather than class-private. Like I said, it makes sense from a namespace point-of-view, but this is an assumption I&#039;ve been making since my CS101 class in college (when I was using Java, which I&#039;ve now learned has the same behavior). From my point of view, making &lt;code&gt;private&lt;/code&gt; mean class-private rather than object-private makes objects less encapsulated, so I guess that&#039;s why I made the assumption.

Anyway, interesting stuff. I&#039;m sure this knowledge will come in handy at some point in the future.</description>
		<content:encoded><![CDATA[<p>Thanks to the two Daniels for the interesting info. I guess I always just assumed that, using the terms the second Daniel mentioned, <code>private</code> means object-private rather than class-private. Like I said, it makes sense from a namespace point-of-view, but this is an assumption I&#8217;ve been making since my CS101 class in college (when I was using Java, which I&#8217;ve now learned has the same behavior). From my point of view, making <code>private</code> mean class-private rather than object-private makes objects less encapsulated, so I guess that&#8217;s why I made the assumption.</p>
<p>Anyway, interesting stuff. I&#8217;m sure this knowledge will come in handy at some point in the future.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

