<?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: Beware of Getters and Setters</title>
	<atom:link href="http://jacksondunstan.com/articles/433/feed" rel="self" type="application/rss+xml" />
	<link>http://jacksondunstan.com/articles/433</link>
	<description>Mastering AS3</description>
	<lastBuildDate>Wed, 08 Sep 2010 19:02:09 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Germain LECOURTOIS</title>
		<link>http://jacksondunstan.com/articles/433/comment-page-1#comment-398</link>
		<dc:creator>Germain LECOURTOIS</dc:creator>
		<pubDate>Thu, 19 Nov 2009 16:03:25 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=433#comment-398</guid>
		<description>I made a test with 10 000 000 iterations and had a getX() method.
On a simple MyPoint class:
public var _x:Number;
public function getX() : Number { return _x;}
public function get x() : Number { return _x;}

Results :
MyPoint.x: 2185 ms
MyPoint.getX: 2444 ms
MyPoint._x: 638 ms</description>
		<content:encoded><![CDATA[<p>I made a test with 10 000 000 iterations and had a getX() method.<br />
On a simple MyPoint class:<br />
public var _x:Number;<br />
public function getX() : Number { return _x;}<br />
public function get x() : Number { return _x;}</p>
<p>Results :<br />
MyPoint.x: 2185 ms<br />
MyPoint.getX: 2444 ms<br />
MyPoint._x: 638 ms</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/433/comment-page-1#comment-363</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Tue, 10 Nov 2009 05:12:47 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=433#comment-363</guid>
		<description>The &lt;tt&gt;MyPoint&lt;/tt&gt; class is the test of getters without using &lt;tt&gt;Sprite&lt;/tt&gt;. I added it because of Keith Peters&#039; comment above.

I&#039;m not sure what you mean by using &lt;tt&gt;Vector&lt;/tt&gt; and &lt;tt&gt;Dictionary&lt;/tt&gt; classes here. How could this be faster than accessing a public variable? Could you provide a brief code example to show the technique? I&#039;d be very interested to see any additional technique for solving the same problem other than what I&#039;ve already discussed in the article.</description>
		<content:encoded><![CDATA[<p>The <tt>MyPoint</tt> class is the test of getters without using <tt>Sprite</tt>. I added it because of Keith Peters&#8217; comment above.</p>
<p>I&#8217;m not sure what you mean by using <tt>Vector</tt> and <tt>Dictionary</tt> classes here. How could this be faster than accessing a public variable? Could you provide a brief code example to show the technique? I&#8217;d be very interested to see any additional technique for solving the same problem other than what I&#8217;ve already discussed in the article.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Elliot Rock</title>
		<link>http://jacksondunstan.com/articles/433/comment-page-1#comment-362</link>
		<dc:creator>Elliot Rock</dc:creator>
		<pubDate>Tue, 10 Nov 2009 04:59:38 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=433#comment-362</guid>
		<description>Interesting test, it is a pretty self evident when you consider a getter setter does more but both contained public vars and getter/setters aren&#039;t great methods at tracking a large amount of iterations of classes/objects.

Both the Vector and dictionary classes are better at retrieving and storing data like you are doing. 

But that is of course irrelevant to what you where trying to prove here. Good point over all, it would be good to see a raw test without sprites or using the display list.</description>
		<content:encoded><![CDATA[<p>Interesting test, it is a pretty self evident when you consider a getter setter does more but both contained public vars and getter/setters aren&#8217;t great methods at tracking a large amount of iterations of classes/objects.</p>
<p>Both the Vector and dictionary classes are better at retrieving and storing data like you are doing. </p>
<p>But that is of course irrelevant to what you where trying to prove here. Good point over all, it would be good to see a raw test without sprites or using the display list.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/433/comment-page-1#comment-357</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Sat, 07 Nov 2009 16:22:24 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=433#comment-357</guid>
		<description>No, &lt;tt&gt;MySprite&lt;/tt&gt; already has public properties I directly access. One can assume the speed would be the same regardless of what the class is named.</description>
		<content:encoded><![CDATA[<p>No, <tt>MySprite</tt> already has public properties I directly access. One can assume the speed would be the same regardless of what the class is named.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Derrick Grigg</title>
		<link>http://jacksondunstan.com/articles/433/comment-page-1#comment-356</link>
		<dc:creator>Derrick Grigg</dc:creator>
		<pubDate>Sat, 07 Nov 2009 12:37:54 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=433#comment-356</guid>
		<description>Did you run a test comparing the access of the getter/setter on the MyPoint class vs setting the __x and __y as public and accessing them directly? That would give you a true apples to apples comparison.</description>
		<content:encoded><![CDATA[<p>Did you run a test comparing the access of the getter/setter on the MyPoint class vs setting the __x and __y as public and accessing them directly? That would give you a true apples to apples comparison.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/433/comment-page-1#comment-355</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Fri, 06 Nov 2009 18:57:44 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=433#comment-355</guid>
		<description>I have updated the article to include a plain getter test. Since I was using the getter and not the setter, I wasn&#039;t changing the display state of the &lt;tt&gt;Sprite&lt;/tt&gt; but I was still inadvertently counting the time required to convert from twips to pixels. Thanks for the correction!</description>
		<content:encoded><![CDATA[<p>I have updated the article to include a plain getter test. Since I was using the getter and not the setter, I wasn&#8217;t changing the display state of the <tt>Sprite</tt> but I was still inadvertently counting the time required to convert from twips to pixels. Thanks for the correction!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keith Peters</title>
		<link>http://jacksondunstan.com/articles/433/comment-page-1#comment-354</link>
		<dc:creator>Keith Peters</dc:creator>
		<pubDate>Fri, 06 Nov 2009 18:32:54 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=433#comment-354</guid>
		<description>The slowdown of sprite&#039;s x and y is not only due to it being a getter/setter rather than a simple variable. Well yes, it has to do with that, but it&#039;s what that setter is doing. I don&#039;t know of all the internals, but minimally, it is rounding it to twips (1/20th of a pixel) and triggering a change in the display state of the sprite. If you want a true test of the difference between a public var and a getter/setter, make your own where all it is doing is setting the private var.

However, the whole twip thing is another reason to keep your own position values and not rely on a sprite&#039;s position. Again, display object positions will always be rounded to the nearest .05 which can cause some serious discrepancies over time. Best to keep it as a separate number value and update the sprite as needed. Goes hand in hand with separating model and view anyway.</description>
		<content:encoded><![CDATA[<p>The slowdown of sprite&#8217;s x and y is not only due to it being a getter/setter rather than a simple variable. Well yes, it has to do with that, but it&#8217;s what that setter is doing. I don&#8217;t know of all the internals, but minimally, it is rounding it to twips (1/20th of a pixel) and triggering a change in the display state of the sprite. If you want a true test of the difference between a public var and a getter/setter, make your own where all it is doing is setting the private var.</p>
<p>However, the whole twip thing is another reason to keep your own position values and not rely on a sprite&#8217;s position. Again, display object positions will always be rounded to the nearest .05 which can cause some serious discrepancies over time. Best to keep it as a separate number value and update the sprite as needed. Goes hand in hand with separating model and view anyway.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
