<?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/"
	>

<channel>
	<title>.toString() &#187; namespace</title>
	<atom:link href="http://www.dottostring.com/tag/namespace/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dottostring.com</link>
	<description>Programming is our passion</description>
	<lastBuildDate>Sun, 04 Oct 2009 15:57:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to namespace your Javascript</title>
		<link>http://www.dottostring.com/2008/11/how-to-namespace-your-javascript/</link>
		<comments>http://www.dottostring.com/2008/11/how-to-namespace-your-javascript/#comments</comments>
		<pubDate>Wed, 05 Nov 2008 18:38:39 +0000</pubDate>
		<dc:creator>Irfan</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[namespace]]></category>

		<guid isPermaLink="false">http://www.dottostring.com/?p=39</guid>
		<description><![CDATA[Put everything in a namespace. This not only avoids collisions with other people&#8217;s scripts but also organize your objects into groups that make sense. Lets start namespacing !
// Using abbreviation of DotToString = DTS
if (typeof DTS == "undefined")
{
	var DTS = {};
}
// Make a function for creating namespaces
DTS.namespace = function() {
	var a=arguments, o=null, i, j, d;
	for [...]]]></description>
			<content:encoded><![CDATA[<p>Put everything in a namespace. This not only avoids collisions with other people&#8217;s scripts but also organize your objects into groups that make sense. Lets start namespacing !</p>
<pre name="code" class="js">// Using abbreviation of DotToString = DTS
if (typeof DTS == "undefined")
{
	var DTS = {};
}</pre>
<pre name="code" class="javascript">// Make a function for creating namespaces
DTS.namespace = function() {
	var a=arguments, o=null, i, j, d;
	for (i=0; i&lt;a.length; i=i+1) {
		d=a[i].split(".");
		o=DTS;

		// DTS is implied, so it is ignored if it is included
		for (j=(d[0] == "DTS") ? 1 : 0; j&lt;d.length; j=j+1) {
			o[d[j]]=o[d[j]] || {};
			o=o[d[j]];
		}
	}

	return o;
};</pre>
<p>and thats all <img src='http://www.dottostring.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Now you can create your own namespaces like this:</p>
<pre name="code" class="javascript">// We can mention our top level namespace
DTS.namespace("DTS.UI.Example");</pre>
<pre name="code" class="javascript">// or we can just skip top level namespace
DTS.namespace("UI.widgets");</pre>
<pre name="code" class="javascript">// or we can have a hybrid case
DTS.namespace("DTS.UI.Example", "UI.widgets");
</pre>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.dottostring.com%2F2008%2F11%2Fhow-to-namespace-your-javascript%2F';
  addthis_title  = 'How+to+namespace+your+Javascript';
  addthis_pub    = 'erfaan';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.dottostring.com/2008/11/how-to-namespace-your-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
