<?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: Injecting Traits into Javascript Objects</title>
	<atom:link href="http://blogs.yellowfish.biz/2009/injecting-traits-into-javascript-objects/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.yellowfish.biz/2009/injecting-traits-into-javascript-objects/</link>
	<description>IT Consulting, Infrastructure, Software &#38; Voip Phone Systems</description>
	<lastBuildDate>Mon, 01 Mar 2010 02:41:18 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Praveen Ray</title>
		<link>http://blogs.yellowfish.biz/2009/injecting-traits-into-javascript-objects/comment-page-1/#comment-339</link>
		<dc:creator>Praveen Ray</dc:creator>
		<pubDate>Sat, 12 Dec 2009 15:50:02 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.yellowfish.biz/?p=234#comment-339</guid>
		<description>The theme is iBlog2 theme by Pagelines</description>
		<content:encoded><![CDATA[<p>The theme is iBlog2 theme by Pagelines</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fabhoinna</title>
		<link>http://blogs.yellowfish.biz/2009/injecting-traits-into-javascript-objects/comment-page-1/#comment-338</link>
		<dc:creator>Fabhoinna</dc:creator>
		<pubDate>Sat, 12 Dec 2009 08:30:39 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.yellowfish.biz/?p=234#comment-338</guid>
		<description>Sry for commenting OFF TOPIC ... which wordpress theme do you use? It looks amazing.</description>
		<content:encoded><![CDATA[<p>Sry for commenting OFF TOPIC &#8230; which wordpress theme do you use? It looks amazing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Seliger</title>
		<link>http://blogs.yellowfish.biz/2009/injecting-traits-into-javascript-objects/comment-page-1/#comment-91</link>
		<dc:creator>Peter Seliger</dc:creator>
		<pubDate>Sat, 10 Oct 2009 01:28:44 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.yellowfish.biz/?p=234#comment-91</guid>
		<description>Hi Praveen,


&gt;&gt; Here’s one simple way to do it in Javascript (using extjs here):

JavaScript&#039;s language design already supports [Trait] implementation
mechanics in its most native way via [Function] objects and its two
caller methods [apply] or [call].

A trait gets written like any constructor function. Your given example
code than will turn into:

var MyTrait = (function () {

	this.xhr = (function (config) {
		return Ext.Ajax.request(config);
	});
	this.submit = (function (basic_form,config) {
		// perform some checks on config 
		// and call basic_form.submit 
   });
   // ... add more utility functions
});

The JavaScript code for applying such behavior onto already existing
instances of whatever kind (var obj = new SomeVeryComplexObjectModel;)
literaly states what it does:

MyTrait.call(obj);

And it is simple as well to make this kind of subtyping (is it allowed
calling it *interface inheritance*?) part of a constructor function:


var SomeVeryComplexObjectModel = (function () {

	MyTrait.call(this); // applying or mixing in the [MyTrait] type

/*
	defining the objects constructing [SomeVeryComplexObjectModel] type
*/
});


How about that defenition of mine, I came up with a while ago, cause
I wanted to make understood myself the languages different approches
and wordings of what I&#039;d like to call Traits in JavaScript too.

  »The concept of &quot;Mixin&quot;s from the perspective of
   JavaScript adds behavior to objects by delegation
   over implemented interfaces. &quot;Trait&quot;s  might be
   the wording that comes closest to this languages
   design.
   Furthermore, &quot;augment&quot; describes far better the
   mechanism behind this special kind of interface
   inheritance than &quot;mix in&quot; does.«

Pleace correct me. If it comes to the basic principles of computer
science I&#039;m merely an interested layman.


so long - peterS.</description>
		<content:encoded><![CDATA[<p>Hi Praveen,</p>
<p>&gt;&gt; Here’s one simple way to do it in Javascript (using extjs here):</p>
<p>JavaScript&#8217;s language design already supports [Trait] implementation<br />
mechanics in its most native way via [Function] objects and its two<br />
caller methods [apply] or [call].</p>
<p>A trait gets written like any constructor function. Your given example<br />
code than will turn into:</p>
<p>var MyTrait = (function () {</p>
<p>	this.xhr = (function (config) {<br />
		return Ext.Ajax.request(config);<br />
	});<br />
	this.submit = (function (basic_form,config) {<br />
		// perform some checks on config<br />
		// and call basic_form.submit<br />
   });<br />
   // &#8230; add more utility functions<br />
});</p>
<p>The JavaScript code for applying such behavior onto already existing<br />
instances of whatever kind (var obj = new SomeVeryComplexObjectModel;)<br />
literaly states what it does:</p>
<p>MyTrait.call(obj);</p>
<p>And it is simple as well to make this kind of subtyping (is it allowed<br />
calling it *interface inheritance*?) part of a constructor function:</p>
<p>var SomeVeryComplexObjectModel = (function () {</p>
<p>	MyTrait.call(this); // applying or mixing in the [MyTrait] type</p>
<p>/*<br />
	defining the objects constructing [SomeVeryComplexObjectModel] type<br />
*/<br />
});</p>
<p>How about that defenition of mine, I came up with a while ago, cause<br />
I wanted to make understood myself the languages different approches<br />
and wordings of what I&#8217;d like to call Traits in JavaScript too.</p>
<p>  »The concept of &#8220;Mixin&#8221;s from the perspective of<br />
   JavaScript adds behavior to objects by delegation<br />
   over implemented interfaces. &#8220;Trait&#8221;s  might be<br />
   the wording that comes closest to this languages<br />
   design.<br />
   Furthermore, &#8220;augment&#8221; describes far better the<br />
   mechanism behind this special kind of interface<br />
   inheritance than &#8220;mix in&#8221; does.«</p>
<p>Pleace correct me. If it comes to the basic principles of computer<br />
science I&#8217;m merely an interested layman.</p>
<p>so long &#8211; peterS.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jay Garcia</title>
		<link>http://blogs.yellowfish.biz/2009/injecting-traits-into-javascript-objects/comment-page-1/#comment-51</link>
		<dc:creator>Jay Garcia</dc:creator>
		<pubDate>Fri, 02 Oct 2009 14:25:48 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.yellowfish.biz/?p=234#comment-51</guid>
		<description>Why create an object reference if you&#039;re not going to use it again?  Also, there is no need to create a constructor just to call the superclass constructor.

var MyGrid = Ext.extend(Ext.grid.GridPanel, {
     // utility functions here
});

That&#039;s it.

One last thing, please encourage the use of &#039;var&#039; when creating variables.</description>
		<content:encoded><![CDATA[<p>Why create an object reference if you&#8217;re not going to use it again?  Also, there is no need to create a constructor just to call the superclass constructor.</p>
<p>var MyGrid = Ext.extend(Ext.grid.GridPanel, {<br />
     // utility functions here<br />
});</p>
<p>That&#8217;s it.</p>
<p>One last thing, please encourage the use of &#8216;var&#8217; when creating variables.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ed Spencer</title>
		<link>http://blogs.yellowfish.biz/2009/injecting-traits-into-javascript-objects/comment-page-1/#comment-50</link>
		<dc:creator>Ed Spencer</dc:creator>
		<pubDate>Fri, 02 Oct 2009 13:38:03 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.yellowfish.biz/?p=234#comment-50</guid>
		<description>I was typing up a reply here but it got a bit long and evolved into a blog post :) Check out http://edspencer.net/2009/10/extjs-modules-and-mixins.html if you&#039;re interested...</description>
		<content:encoded><![CDATA[<p>I was typing up a reply here but it got a bit long and evolved into a blog post <img src='http://blogs.yellowfish.biz/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Check out <a href="http://edspencer.net/2009/10/extjs-modules-and-mixins.html" rel="nofollow">http://edspencer.net/2009/10/extjs-modules-and-mixins.html</a> if you&#8217;re interested&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ExtJS modules and mixins : Ed Spencer</title>
		<link>http://blogs.yellowfish.biz/2009/injecting-traits-into-javascript-objects/comment-page-1/#comment-49</link>
		<dc:creator>ExtJS modules and mixins : Ed Spencer</dc:creator>
		<pubDate>Fri, 02 Oct 2009 13:33:02 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.yellowfish.biz/?p=234#comment-49</guid>
		<description>[...] few days back Praveen Ray posted about &#8220;Traits&#8221; in Ext JS. What he described is pretty much what we&#8217;d call Modules in the Ruby world, and how to mix [...]</description>
		<content:encoded><![CDATA[<p>[...] few days back Praveen Ray posted about &#8220;Traits&#8221; in Ext JS. What he described is pretty much what we&#8217;d call Modules in the Ruby world, and how to mix [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steffen Hiller</title>
		<link>http://blogs.yellowfish.biz/2009/injecting-traits-into-javascript-objects/comment-page-1/#comment-46</link>
		<dc:creator>Steffen Hiller</dc:creator>
		<pubDate>Wed, 30 Sep 2009 17:59:42 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.yellowfish.biz/?p=234#comment-46</guid>
		<description>Hey Praveen,

I think you don&#039;t need the &#039;function MyGrid(config) {MyGrid.superclass.constructor.call(this,config)}&#039; line (in case you don&#039;t override the constructor).

Just &#039;MyGrid = Ext.extend(Ext.grid.GridPanel, MyTrait);&#039; should work in your example, too.

Never heard the name of Trait, in Ruby I would call this a module.

Cheers,
Steffen</description>
		<content:encoded><![CDATA[<p>Hey Praveen,</p>
<p>I think you don&#8217;t need the &#8216;function MyGrid(config) {MyGrid.superclass.constructor.call(this,config)}&#8217; line (in case you don&#8217;t override the constructor).</p>
<p>Just &#8216;MyGrid = Ext.extend(Ext.grid.GridPanel, MyTrait);&#8217; should work in your example, too.</p>
<p>Never heard the name of Trait, in Ruby I would call this a module.</p>
<p>Cheers,<br />
Steffen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Scott</title>
		<link>http://blogs.yellowfish.biz/2009/injecting-traits-into-javascript-objects/comment-page-1/#comment-44</link>
		<dc:creator>Chris Scott</dc:creator>
		<pubDate>Wed, 30 Sep 2009 17:29:01 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.yellowfish.biz/?p=234#comment-44</guid>
		<description>You should define and xtype for your MyGrid, augmented with MyTrait.

Ext.reg(&#039;my-grid&#039;, MyGrid);

var myGrid = Ext.ComponentMgr.create({xtype: &#039;my-grid&#039;, title: &quot;My Grid&quot;});</description>
		<content:encoded><![CDATA[<p>You should define and xtype for your MyGrid, augmented with MyTrait.</p>
<p>Ext.reg(&#8217;my-grid&#8217;, MyGrid);</p>
<p>var myGrid = Ext.ComponentMgr.create({xtype: &#8216;my-grid&#8217;, title: &#8220;My Grid&#8221;});</p>
]]></content:encoded>
	</item>
</channel>
</rss>
