<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>enter the pirate &#187; JavaScript</title>
	<atom:link href="http://enterthepirate.wordpress.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://enterthepirate.wordpress.com</link>
	<description>A poorly maintained blog of technology</description>
	<lastBuildDate>Tue, 11 Aug 2009 18:21:46 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='enterthepirate.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/9c70ecb76cb3997795bf316b00c4f269?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>enter the pirate &#187; JavaScript</title>
		<link>http://enterthepirate.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://enterthepirate.wordpress.com/osd.xml" title="enter the pirate" />
		<item>
		<title>Creating Classes in Prototype, MooTools</title>
		<link>http://enterthepirate.wordpress.com/2008/05/02/creating-classes-in-prototype-mootools/</link>
		<comments>http://enterthepirate.wordpress.com/2008/05/02/creating-classes-in-prototype-mootools/#comments</comments>
		<pubDate>Fri, 02 May 2008 16:41:49 +0000</pubDate>
		<dc:creator>enterthepirate</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[JavaScript framework]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[Object oriented]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[Prototype]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://enterthepirate.wordpress.com/?p=24</guid>
		<description><![CDATA[I come from the object oriented world, as I&#8217;m sure many of you do. Creating a class is a great way to write portable code that is easy to understand, and easy for other developers to work with.
This is just a brief overview of how two of the more popular JavaScript frameworks implement classes. Prototype [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=enterthepirate.wordpress.com&blog=3609243&post=24&subd=enterthepirate&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I come from the object oriented world, as I&#8217;m sure many of you do. Creating a class is a great way to write portable code that is easy to understand, and easy for other developers to work with.</p>
<p>This is just a brief overview of how two of the more popular JavaScript frameworks implement classes. Prototype v.1.6.0.2 and MooTools v.1.11 is assumed. This is a class used in an application that is passing data back to server-side code via the ASP.NET ClientScript.RegisterClientScriptBlock functionality.</p>
<blockquote><p><strong>MooTools</strong></p>
<p><em>Let&#8217;s create a new class, and add a method to the class that we&#8217;ll use later in a project.</em></p>
<p><code><span style="color:#0000ff;">var</span> Filter = <span style="color:#0000ff;">new</span> Class({<br />
initialize: <span style="color:#0000ff;">function</span>(type, value) {<br />
<span style="color:#0000ff;"> this</span>.type = type;<br />
<span style="color:#0000ff;"> this</span>.value = value;<br />
}<br />
});</code></p>
<p><em>Now let&#8217;s add our method for the class.</em></p>
<p><code>Filter.implement({<br />
toReq: <span style="color:#0000ff;">function</span>() {<br />
<span style="color:#0000ff;"> return</span> <span style="color:#0000ff;">this</span>.type + ':' + <span style="color:#0000ff;">this</span>.value;<br />
}<br />
});</code></p></blockquote>
<p>I&#8217;m using MooTools in the live application, and I&#8217;m very happy with the performance. Now let&#8217;s take a look at how to do the same thing in Prototype.</p>
<blockquote><p><strong>Prototype</strong></p>
<p><em>With Prototype, we&#8217;ll create our class and it&#8217;s constructor as well as our method in the same block of code.</em></p>
<p><code><span style="color:#0000ff;">var</span> Filter = Class.create({<br />
initialize: <span style="color:#0000ff;">function</span>(type, value) {<br />
<span style="color:#0000ff;"> this</span>.type = type;<br />
<span style="color:#0000ff;"> this</span>.value = value;<br />
},<br />
toReq: <span style="color:#0000ff;">function</span>() {<br />
<span style="color:#0000ff;"> return</span> <span style="color:#0000ff;">this</span>.type + ':' + <span style="color:#0000ff;">this</span>.value;<br />
}<br />
});</code></p></blockquote>
<p>The preference is entirely up to the programmer and their background, personal experience.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/enterthepirate.wordpress.com/24/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/enterthepirate.wordpress.com/24/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/enterthepirate.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/enterthepirate.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/enterthepirate.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/enterthepirate.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/enterthepirate.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/enterthepirate.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/enterthepirate.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/enterthepirate.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/enterthepirate.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/enterthepirate.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=enterthepirate.wordpress.com&blog=3609243&post=24&subd=enterthepirate&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://enterthepirate.wordpress.com/2008/05/02/creating-classes-in-prototype-mootools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5f3e17d91e3907d5bdebc25dad00e233?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">enterthepirate</media:title>
		</media:content>
	</item>
	</channel>
</rss>