<?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: Revealing Prototype Pattern: Pros and Cons</title>
	<atom:link href="http://robpaveza.net/revealing-prototype-pattern-pros-and-cons/feed" rel="self" type="application/rss+xml" />
	<link>http://robpaveza.net/revealing-prototype-pattern-pros-and-cons</link>
	<description>Like with scissors, only more dangerous</description>
	<lastBuildDate>Wed, 22 Feb 2012 02:09:36 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Gene Karasev</title>
		<link>http://robpaveza.net/revealing-prototype-pattern-pros-and-cons/comment-page-1#comment-251</link>
		<dc:creator>Gene Karasev</dc:creator>
		<pubDate>Wed, 25 Jan 2012 19:31:03 +0000</pubDate>
		<guid isPermaLink="false">http://robpaveza.net/?p=129#comment-251</guid>
		<description>Thank you a lot for the great article!

My way of using Dan&#039;s pattern is to define all public properties (not methods) in the object __pthis:

 function Image(width, height)
    {
        // standard header
        this.__pthis = {};
        var pthis = this.__pthis;
        // end standard header
        //
        pthis.width = width;
        pthis.height = height;
        //
        this.__construct();
    }

And then in a method I can do:
function multiply()
{
        var pthis = this.__pthis; // standard line for all the methods to make __pthis local variable 
        return pthis.width * pthis.height; // example of how to access the properties
}

So I&#039;ve got only one public variable __pthis (except for the public methods) and its easy to remember not to touch it from the outside code.

When I call one method from another method I use myMethod.call(this, arg1, arg2) as Dan recommends, to pass context. For me there&#039;s the only inconvenient thing in that pattern I have to do - using call() method to call my methods. But I have the maximum speed and memory saving (it can be good especially for mobile devices).</description>
		<content:encoded><![CDATA[<p>Thank you a lot for the great article!</p>
<p>My way of using Dan&#8217;s pattern is to define all public properties (not methods) in the object __pthis:</p>
<p> function Image(width, height)<br />
    {<br />
        // standard header<br />
        this.__pthis = {};<br />
        var pthis = this.__pthis;<br />
        // end standard header<br />
        //<br />
        pthis.width = width;<br />
        pthis.height = height;<br />
        //<br />
        this.__construct();<br />
    }</p>
<p>And then in a method I can do:<br />
function multiply()<br />
{<br />
        var pthis = this.__pthis; // standard line for all the methods to make __pthis local variable<br />
        return pthis.width * pthis.height; // example of how to access the properties<br />
}</p>
<p>So I&#8217;ve got only one public variable __pthis (except for the public methods) and its easy to remember not to touch it from the outside code.</p>
<p>When I call one method from another method I use myMethod.call(this, arg1, arg2) as Dan recommends, to pass context. For me there&#8217;s the only inconvenient thing in that pattern I have to do &#8211; using call() method to call my methods. But I have the maximum speed and memory saving (it can be good especially for mobile devices).</p>
]]></content:encoded>
	</item>
</channel>
</rss>

