<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Tech+Life+Music</title>
	
	<link>http://richardneililagan.com</link>
	<description>The not-so-secret website lair of Richard Neil Ilagan</description>
	<lastBuildDate>Fri, 20 Jan 2012 13:00:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/richardneililagan" /><feedburner:info uri="richardneililagan" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Learning from the HTML5 Boilerplate, Part 3</title>
		<link>http://feedproxy.google.com/~r/richardneililagan/~3/xCAjbc0_xeQ/</link>
		<comments>http://richardneililagan.com/2012/01/learning-html5-boilerplate-part-3/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 13:00:07 +0000</pubDate>
		<dc:creator>Richard Neil Ilagan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[boilerplate]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[chrome frame]]></category>
		<category><![CDATA[chromium]]></category>
		<category><![CDATA[google chrome]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[html5 boilerplate]]></category>

		<guid isPermaLink="false">http://richardneililagan.com/?p=1377</guid>
		<description><![CDATA[<p><a href="http://richardneililagan.com/2012/01/learning-html5-boilerplate-part-3/">Learning from the HTML5 Boilerplate, Part 3</a> was originally published in <a href="http://richardneililagan.com">Tech+Life+Music</a>.</p><p>One of the easiest things you can do to make sure the dreaded Internet Explorer 6 is up to reasonable snuff is to include a single Javascript snippet on your page.</p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://richardneililagan.com/2012/01/learning-html5-boilerplate-part-3/">Learning from the HTML5 Boilerplate, Part 3</a> was originally published in <a href="http://richardneililagan.com">Tech+Life+Music</a>.</p><p>On the topic of <a href="http://richardneililagan.com/2012/01/learning-html5-boilerplate-part-2/" title="Learning from the HTML5 Boilerplate, Part 2">making Internet Explorer behave</a>, one of the easiest things you can do to make sure the dreaded Internet Explorer 6 is up to reasonable snuff is to include a single Javascript snippet on your page.</p>
<h2>Chrome Frame</h2>
<p>The Google Chrome Frame <a href="http://blog.chromium.org/2009/09/introducing-google-chrome-frame.html" title="Introducing Google Chrome Frame" target="_blank">is not new</a>. It&#8217;s an IE plugin that acts as an additional rendering engine that delivers more or less the same features, offerings, and HTML5 + CSS3 goodness as the standard Google Chrome. Long story short, it&#8217;s a Google Chrome running <em>inside</em> your Internet Explorer. The ultimate problem was that it needed to be installed by <a href="http://kb.iu.edu/data/aorq.html" title="What are administrative rights?" target="_blank">a user with administrative rights</a>.</p>
<p>And then <a href="http://blog.chromium.org/2011/06/introducing-non-admin-chrome-frame.html" title="Introducing Non-Admin Chrome Frame" target="_blank">the &#8220;non-admin&#8221; Chrome Frame came around</a>. It&#8217;s a Chrome Frame that can be installed by any user on a client computer. Now, there&#8217;s virtually no reason anymore <strong>not</strong> to install it if you&#8217;re stuck on a legacy Internet Explorer for some reason.</p>
<h2>Getting users to install Chrome Frame</h2>
<p>Now, in order to be able to deliver all the cutting-edge HTML 5 rainbow goodness for your clients, you just have to make sure that install the Google Chrome Frame. How to do that?</p>
<p>Just include the following inside your markup, preferably right before the closing <code></body></code> tag:</p>

<div class="wp_codebox"><table><tr id="p13771"><td class="code" id="p1377code1"><pre class="xml" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!--[if lt IE 7 ]&gt;</span>
<span style="color: #808080; font-style: italic;">  &lt;script src=&quot;//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js&quot;&gt;&lt;/script&gt;</span>
<span style="color: #808080; font-style: italic;">  &lt;script&gt;window.attachEvent(&quot;onload&quot;,function(){CFInstall.check({mode:&quot;overlay&quot;})})&lt;/script&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;![endif]--&gt;</span></pre></td></tr></table></div>

<p>That&#8217;s pretty much it. If your webpage is loaded inside an Internet Explorer 6 or lower, a <strong>very</strong> prominent overlay attempts to convince your user to install Chrome Frame.</p>
<p><a href="http://richardneililagan.com/wp-content/uploads/2012/01/chromeframe.png"><img src="http://richardneililagan.com/wp-content/uploads/2012/01/chromeframe.png" alt="Learning from the HTML5 Boilerplate, Part 3" title="Google Chrome Frame" width="545" height="414" class="aligncenter size-full wp-image-1378" /></a></p>
<p>Of course, to make the most use of Chrome Frame, you&#8217;ll have to include the appropriate <code>X-UA-Compatible</code> value as detailed in <a href="http://richardneililagan.com/2012/01/learning-html5-boilerplate-part-2/" title="Learning from the HTML5 Boilerplate, Part 2" target="_blank">this HTML5 Boilerplate article</a>.</p>
<p>If you want to know more about the Google Chrome Frame, <a href="http://www.chromium.org/developers/how-tos/chrome-frame-getting-started/chrome-frame-faq" title="Google Chrome Frame FAQ" target="_blank">hop on over to the FAQ</a>.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/richardneililagan?a=xCAjbc0_xeQ:7OmQYLAA3LQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/richardneililagan?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/richardneililagan?a=xCAjbc0_xeQ:7OmQYLAA3LQ:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/richardneililagan?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/richardneililagan?a=xCAjbc0_xeQ:7OmQYLAA3LQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/richardneililagan?i=xCAjbc0_xeQ:7OmQYLAA3LQ:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/richardneililagan/~4/xCAjbc0_xeQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://richardneililagan.com/2012/01/learning-html5-boilerplate-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://richardneililagan.com/2012/01/learning-html5-boilerplate-part-3/</feedburner:origLink></item>
		<item>
		<title>About SOPA and PIPA, aka Why the Blackout aka On Being Filipino</title>
		<link>http://feedproxy.google.com/~r/richardneililagan/~3/rxQpO2V-u6Q/</link>
		<comments>http://richardneililagan.com/2012/01/sopa-pipa-aka-blackout-aka-filipino/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 13:44:33 +0000</pubDate>
		<dc:creator>Richard Neil Ilagan</dc:creator>
				<category><![CDATA[Other Computers and Technology]]></category>
		<category><![CDATA[blackout]]></category>
		<category><![CDATA[pipa]]></category>
		<category><![CDATA[sopa]]></category>
		<category><![CDATA[stop pipa]]></category>
		<category><![CDATA[stop sopa]]></category>

		<guid isPermaLink="false">http://richardneililagan.com/?p=1368</guid>
		<description><![CDATA[<p><a href="http://richardneililagan.com/2012/01/sopa-pipa-aka-blackout-aka-filipino/">About SOPA and PIPA, aka Why the Blackout aka On Being Filipino</a> was originally published in <a href="http://richardneililagan.com">Tech+Life+Music</a>.</p><p>Why the blackout? Why the care for stopping SOPA and PIPA?</p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://richardneililagan.com/2012/01/sopa-pipa-aka-blackout-aka-filipino/">About SOPA and PIPA, aka Why the Blackout aka On Being Filipino</a> was originally published in <a href="http://richardneililagan.com">Tech+Life+Music</a>.</p><p><img src="http://richardneililagan.com/wp-content/uploads/2012/01/sopa.png" alt="About SOPA and PIPA, aka Why the Blackout aka On Being Filipino" title="This is what the web could like under SOPA / PIPA." width="545" height="250" class="aligncenter size-full wp-image-1370" /></p>
<p>This blog is written by a Filipino, maintained by a Filipino, and proudly Filipino. Most of the content were typed by my own hand, code crafted by my own mind, and none of it is infringing copyright in whatsoever way (hooray for open source).</p>
<p>So why the blackout? Why the care for stopping SOPA and PIPA?</p>
<p><span id="more-1368"></span></p>
<aside>Want to know more about SOPA and PIPA? Hop on over to the <a href="http://www.sopablackout.org/learnmore/" title="SOPA Blackout" target="_blank">SOPA Blackout landing page</a>.</aside>
<p>Honestly, this video gets all the explaining done quickly and effectively, so I&#8217;ll just coax you to watch it in its entirety.</p>
<p><iframe src="http://player.vimeo.com/video/31100268?byline=0&amp;portrait=0" width="545" height="307" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></p>
<p>January 18 is Stop SOPA Day. I encourage you to join sites worldwide in protest. If you run a WordPress, Tumblr, blog or whatever, post about it / embed the video. </p>
<p>If you&#8217;re on Twitter, do tweet about this. Here, I&#8217;ll make it even easier for you:</p>
<p><a href="https://twitter.com/share" class="twitter-share-button" data-text="Help stop SOPA / PIPA." data-via="techlifemusic" data-related="techlifemusic" data-hashtags="sopa">Tweet</a><br />
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></p>
<p>If you&#8217;re on Facebook, likewise. Post about it, tell your friends about it, and hopefully we can help generate a bit of additional buzz.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/richardneililagan?a=rxQpO2V-u6Q:zZrKTWKmhdk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/richardneililagan?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/richardneililagan?a=rxQpO2V-u6Q:zZrKTWKmhdk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/richardneililagan?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/richardneililagan?a=rxQpO2V-u6Q:zZrKTWKmhdk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/richardneililagan?i=rxQpO2V-u6Q:zZrKTWKmhdk:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/richardneililagan/~4/rxQpO2V-u6Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://richardneililagan.com/2012/01/sopa-pipa-aka-blackout-aka-filipino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://richardneililagan.com/2012/01/sopa-pipa-aka-blackout-aka-filipino/</feedburner:origLink></item>
		<item>
		<title>Learning from the HTML5 Boilerplate, Part 2</title>
		<link>http://feedproxy.google.com/~r/richardneililagan/~3/UWNX6bg3snk/</link>
		<comments>http://richardneililagan.com/2012/01/learning-html5-boilerplate-part-2/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 12:22:46 +0000</pubDate>
		<dc:creator>Richard Neil Ilagan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[boilerplate]]></category>
		<category><![CDATA[html 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[html5 boilerplate]]></category>
		<category><![CDATA[iis]]></category>
		<category><![CDATA[web programming]]></category>
		<category><![CDATA[x-ua-compatible]]></category>

		<guid isPermaLink="false">http://richardneililagan.com/?p=1352</guid>
		<description><![CDATA[<p><a href="http://richardneililagan.com/2012/01/learning-html5-boilerplate-part-2/">Learning from the HTML5 Boilerplate, Part 2</a> was originally published in <a href="http://richardneililagan.com">Tech+Life+Music</a>.</p><p>Internet Explorer definitely bites when you're creating web pages. Learn how to make it IE behave easier, as shown by code snippets from the HTML5 Boilerplate.</p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://richardneililagan.com/2012/01/learning-html5-boilerplate-part-2/">Learning from the HTML5 Boilerplate, Part 2</a> was originally published in <a href="http://richardneililagan.com">Tech+Life+Music</a>.</p><p>The HTML5 Boilerplate is well-known across web programmers as a powerful starting template for (as the project homepage puts it) building <strong>fast, robust, future-proof sites</strong>. Out of the box, it provides HTML, CSS and Javascript code arranged in such a way to drive as much <em>oomph</em> into your pages as possible. Every nook, cranny, and design decision borrows from widely-accepted standards, and is supported by countless hours of research and testing.</p>
<p>While the HTML5 Boilerplate is awesome as a starting foundation for building awesome sites, it is also packed with code snippets and patterns you should be using for your projects. Just in case you&#8217;re not using the HTML5 Boilerplate for some reason.</p>
<p><span id="more-1352"></span></p>
<h2>Making Internet Explorer behave</h2>
<p>As if it wasn&#8217;t enough that web developers had to keep track of different Internet Explorer versions, it must also be said that computers that run IE also have multiple rendering engines. That is, if a user had IE 8, for example, you can be sure that it has the IE 8 rendering engine. However, it also has a readily available mock of the IE 7 engine as well, so a version 8 Internet Explorer may render a page as if it was version 7. If that wasn&#8217;t enough, it must also be said that these rendering engines aren&#8217;t exact copies: a version 8 IE using the version 7 rendering engine will not behave in the exact same way as a true blue version 7 IE. And that sucks.</p>
<p>Circumstantially, sites viewed <em>from an intranet</em> also trigger <strong>Compatibility View</strong>, something like a glorified <em>quirks mode</em>, by default. That sucks even more.</p>
<p>As it turns out, you can explicitly tell Internet Explorer browsers to use its latest available rendering engine using a meta tag:</p>

<div class="wp_codebox"><table><tr id="p13522"><td class="code" id="p1352code2"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;meta</span> <span style="color: #000066;">http-equiv</span>=<span style="color: #ff0000;">&quot;X-UA-Compatible&quot;</span> <span style="color: #000066;">content</span>=<span style="color: #ff0000;">&quot;IE=edge,chrome=1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></td></tr></table></div>

<p>The <code>IE=edge</code> half of the meta value tells Internet Explorer to use its latest rendering engine for your page. That, in itself, is already a boon and a half. </p>
<p>The <code>chrome=1</code> part tells it to use the Chrome Frame rendering engine if it is installed on the client computer, which basically brings Chrome rendering power to Internet Explorer (yes, even version 6).</p>
<h2>Taking it one notch higher</h2>
<p>Now, this doesn&#8217;t come without any imperfections. First of all, this won&#8217;t work completely as expected inside a conditional comment, so you might as well scratch that idea.</p>
<p>Secondly (and arguably more important to some), is that this line breaks validation. Now, to some, that can be quite a deal breaker.</p>
<p>If you&#8217;re absolutely picky about your HTML validation (&#8217;cause I&#8217;m most often not), a way to work around this is to send the meta value above as an <strong>HTTP header</strong> instead. That should work just as well.</p>
<aside>If you&#8217;re unfamiliar, right before a server sends a web page to your browser, it sends a bunch of text called <strong>HTTP headers</strong>. This chunk of text contains information that your browser needs to know to be able to recognize, render, and react to the data it will be receiving (which, for most cases, is an HTML page). The idea presented here will send the <strong>X-UA-Compatible</strong> meta value as part of the HTTP headers sent with your page, and therefore will not break validation as it is not found right smack in the middle of your HTML markup.</aside>
<p>If you are hosting from an Apache web server, you can send the <code>X-UA-Compatible</code> headers by editing your <code>httpd.conf</code> file and adding in the following:</p>

<div class="wp_codebox"><table><tr id="p13523"><td class="code" id="p1352code3"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Location</span> /mypath<span style="color: #000000; font-weight: bold;">&gt;</span></span>
    Header set X-UA-Compatible &quot;IE=edge,chrome=1&quot;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Location<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>If you are serving off an IIS server, the easiest way to send a custom header is to set a custom configuration setting in your <code>web.config</code> file:</p>

<div class="wp_codebox"><table><tr id="p13524"><td class="code" id="p1352code4"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;system.webServer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #808080; font-style: italic;">&lt;!-- ... --&gt;</span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;httpProtocol<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;customHeaders<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
           <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;X-UA-Compatible&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;IE=edge,chrome=1&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/customHeaders<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/httpProtocol<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!-- ... --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/system.webServer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Doing any of the above let&#8217;s you completely remove the <code><meta></code> tag from your markup.</p>
<p><em>You might want to read the other articles in this series as well:</em></p>
<ul>
<li><a href="http://richardneililagan.com/2012/01/learning-html5-boilerplate-part-1/" title="Learning from the HTML5 Boilerplate, Part 1">Part 1 : Conditional HTML tags</a>
<li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/richardneililagan?a=UWNX6bg3snk:TdxYhgzhwss:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/richardneililagan?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/richardneililagan?a=UWNX6bg3snk:TdxYhgzhwss:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/richardneililagan?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/richardneililagan?a=UWNX6bg3snk:TdxYhgzhwss:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/richardneililagan?i=UWNX6bg3snk:TdxYhgzhwss:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/richardneililagan/~4/UWNX6bg3snk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://richardneililagan.com/2012/01/learning-html5-boilerplate-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://richardneililagan.com/2012/01/learning-html5-boilerplate-part-2/</feedburner:origLink></item>
		<item>
		<title>Learning from the HTML5 Boilerplate, Part 1</title>
		<link>http://feedproxy.google.com/~r/richardneililagan/~3/GmphWu6wenM/</link>
		<comments>http://richardneililagan.com/2012/01/learning-html5-boilerplate-part-1/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 14:57:07 +0000</pubDate>
		<dc:creator>Richard Neil Ilagan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[boilerplate]]></category>
		<category><![CDATA[html 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[html5 boilerplate]]></category>
		<category><![CDATA[web programming]]></category>

		<guid isPermaLink="false">http://richardneililagan.com/?p=1325</guid>
		<description><![CDATA[<p><a href="http://richardneililagan.com/2012/01/learning-html5-boilerplate-part-1/">Learning from the HTML5 Boilerplate, Part 1</a> was originally published in <a href="http://richardneililagan.com">Tech+Life+Music</a>.</p><p>Read about the HTML5 Boilerplate's take on conditional comments and CSS hacks, along with what alternative it proposes and why.</p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://richardneililagan.com/2012/01/learning-html5-boilerplate-part-1/">Learning from the HTML5 Boilerplate, Part 1</a> was originally published in <a href="http://richardneililagan.com">Tech+Life+Music</a>.</p><p>The HTML5 Boilerplate is well-known across web programmers as a powerful starting template for (as the project homepage puts it) building <strong>fast, robust, future-proof sites</strong>. Out of the box, it provides HTML, CSS and Javascript code arranged in such a way to drive as much <em>oomph</em> into your pages as possible. Every nook, cranny, and design decision borrows from widely-accepted standards, and is supported by countless hours of research and testing.</p>
<p>While the HTML5 Boilerplate is awesome as a starting foundation for building awesome sites, it is also packed with code snippets and patterns you should be using for your projects. Just in case you&#8217;re not using the HTML5 Boilerplate for some reason.<br />
<span id="more-1325"></span></p>
<h2>Making browsers behave the same way</h2>
<p>Browsers are not made equal. And this makes our work that much harder. </p>
<p>Different browsers (and browser versions) all behave differently, and so it is not uncommon to see code like this:</p>

<div class="wp_codebox"><table><tr id="p13255"><td class="code" id="p1325code5"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;style.css&quot;</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #808080; font-style: italic;">&lt;!--[if lte IE7]&gt;&lt;link href=&quot;style.ie7.css&quot; rel=&quot;stylesheet&quot; /&gt;&lt;![endif]--&gt;</span></pre></td></tr></table></div>

<p><a href="http://www.quirksmode.org/css/condcom.html" title="Conditional comments : Quirksmode" target="_blank">Conditional comments</a> such as these are meant to load different asset files into the HTML document, depending on whether or not a specific version of Internet Explorer (or even just Internet Explorer) is used. (Yes, IE is <strong>that</strong> notorious.) It&#8217;s meant to introduce additional assets that enforce additional rules that make sure that misbehaving browser quirks render as consistently as possible.</p>
<aside>While conditional comments are primarily intended for IE, CSS hacks rely on browser bugs and quirks, and can therefore be used for taming other browser quirks.</aside>
<p>Alternatively, one can also make use of <a href="http://paulirish.com/2009/browser-specific-css-hacks/" title="Browser-specific CSS hacks" target="_blank">CSS hacks</a>.</p>

<div class="wp_codebox"><table><tr id="p13256"><td class="code" id="p1325code6"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#content</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span> _margin<span style="color: #00AA00;">:</span><span style="color: #933;">20px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>CSS hacks don&#8217;t validate, and rely on browser bugs. Good luck to you when those bugs get patched.</p>
<p>Conditional comments, on the other hand, also present a few disadvantages:</p>
<ol>
<li>They introduce additional (arguably unnecessary) HTTP requests.</li>
<li>They have to be located in the <code>&lt;head&gt;</code>, which means that they can block loading and rendering.</li>
<li>Just imagine the added complexity of working with multiple stylesheets.</li>
<li>Conditional comments can significantly slow your page down due to <a href="http://webforscher.wordpress.com/2010/05/20/ie-6-slowing-down-ie-8/" title="IE6 slowing down IE8" target="_blank">a browser bug in Internet Explorer 8</a>.</li>
</ol>
<h2>Conditional HTML tags</h2>
<p>To address these, the HTML5 Boilerplate uses the following markup instead:</p>

<div class="wp_codebox"><table><tr id="p13257"><td class="code" id="p1325code7"><pre class="xml" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!--[if lt IE 7 ]&gt; &lt;html class=&quot;ie6 no-js oldie&quot;&gt; &lt;![endif]--&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!--[if IE 7 ]&gt;    &lt;html class=&quot;ie7 no-js oldie&quot;&gt; &lt;![endif]--&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!--[if IE 8 ]&gt;    &lt;html class=&quot;ie8 no-js oldie&quot;&gt; &lt;![endif]--&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!--[if IE 9 ]&gt;    &lt;html class=&quot;ie9 no-js&quot;&gt; &lt;![endif]--&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!--[if (gt IE 9)|!(IE)]&gt;&lt;!--&gt;</span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;no-js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span> <span style="color: #808080; font-style: italic;">&lt;!--&lt;![endif]--&gt;</span></pre></td></tr></table></div>

<p>The HTML5 Boilerplate uses conditional comments to dynamically assign classes to the <code>&lt;html&gt;</code> tag. However, since none of these comments are used to load asset files into the page, the previously mentioned browser bug does not occur.</p>
<aside>If you really must use conditional comments to load external files into your page, make sure to include <code>&lt;!--[if IE]&gt;&lt;![endif]--&gt;</code> in your page right after the <code>&lt;head&gt;</code> tag (or as close to the top of your page as possible). This also prevents said browser bug.</aside>
<p>With this markup, your <code>&lt;html&gt;</code> tag dynamically gets assigned a corresponding <em>iex</em> class that you can target in your CSS in a valid manner:</p>

<div class="wp_codebox"><table><tr id="p13258"><td class="code" id="p1325code8"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#content</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.ie7</span> <span style="color: #cc00cc;">#content</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>This promotes the use of a single stylesheet for your page, and (hopefully) keeps related style rules together for easier maintainability. This markup <em>still</em> does not validate, but what&#8217;s arguably more important is that your page renders correctly in any browser nonetheless.</p>
<p>If you&#8217;re wondering what the <code>no-js</code> class is, it is used by <a href="http://www.modernizr.com/" title="Modernizr" target="_blank">Modernizr</a>, a Javascript library that helps you build future-proof pages by allowing you to detect a browser&#8217;s capabilities, and react accordingly. When it loads, it changes the <code>no-js</code> class to <code>js</code>, letting you know if Javascript is enabled in a client&#8217;s browser.</p>
<p>Modernizr is included with HTML5 Boilerplate out of the box. We&#8217;ll discuss using it effectively in a future post.</p>
<p><em>You might want to read the other articles in this series as well:</em></p>
<ul>
<li><a href="http://richardneililagan.com/2012/01/learning-html5-boilerplate-part-2/" title="Learning from the HTML5 Boilerplate, Part 2">Part 2 : X-UA-Compatible, and making Internet Explorer behave</a>
<li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/richardneililagan?a=GmphWu6wenM:fxhWJZvX0zw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/richardneililagan?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/richardneililagan?a=GmphWu6wenM:fxhWJZvX0zw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/richardneililagan?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/richardneililagan?a=GmphWu6wenM:fxhWJZvX0zw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/richardneililagan?i=GmphWu6wenM:fxhWJZvX0zw:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/richardneililagan/~4/GmphWu6wenM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://richardneililagan.com/2012/01/learning-html5-boilerplate-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://richardneililagan.com/2012/01/learning-html5-boilerplate-part-1/</feedburner:origLink></item>
		<item>
		<title>The understated beauty of jQuery’s new .on() and .off() functions</title>
		<link>http://feedproxy.google.com/~r/richardneililagan/~3/JZcrD2IAtlc/</link>
		<comments>http://richardneililagan.com/2011/12/the-understated-beauty-of-jquerys-new-on-and-off-functions/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 09:18:34 +0000</pubDate>
		<dc:creator>Richard Neil Ilagan</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://richardneililagan.com/?p=1307</guid>
		<description><![CDATA[<p><a href="http://richardneililagan.com/2011/12/the-understated-beauty-of-jquerys-new-on-and-off-functions/">The understated beauty of jQuery&#8217;s new .on() and .off() functions</a> was originally published in <a href="http://richardneililagan.com">Tech+Life+Music</a>.</p><p>The new .on() and .off() functions both make you a better jQuery programmer just by using them. It's magic. No, seriously.</p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://richardneililagan.com/2011/12/the-understated-beauty-of-jquerys-new-on-and-off-functions/">The understated beauty of jQuery&#8217;s new .on() and .off() functions</a> was originally published in <a href="http://richardneililagan.com">Tech+Life+Music</a>.</p><p>The latest version of jQuery (that is, 1.7.1, or 1.7.x) has been around for a good while already, and the new <code>.on()</code> and <code>.off()</code> functions <strong>still</strong> come to me as the shiniest new toys that came along with it. Not only are they shorter, more intuitive and better at what they do, but they also <strong>promote (generally) accepted jQuery good practice</strong> that has been around for quite a while.</p>
<h2>What am I talking about?</h2>
<p>If you&#8217;re any jQuery programmer worth your salt, then you know of, <strong>at the very least</strong>, <code>.bind()</code> and <code>.live()</code> when it comes to DOM event handling. The main difference being that the former is preferred for present elements, and the latter is &#8220;mandatory&#8221; for future element handling.</p>
<p>One or two rungs up the jQuery programmer ladder, and you&#8217;d know of <code>.delegate()</code> as well. If you actually use it with convicted priority over <code>.live()</code>, then you&#8217;re golden. An explanation of why would require <a href="http://www.alfajango.com/blog/the-difference-between-jquerys-bind-live-and-delegate/" title="The difference between jQuery's bind, live and delegate" target="_blank">a good grasp of how jQuery handles events behind the scenes</a>, followed by a primer on <a href="http://www.ultimatewebtips.com/why-jquery-live-is-a-bad-option-to-use/" title="Why jQuery live is a bad option to use" target="_blank">why using .live() is bad</a>.</p>
<p>It&#8217;s admittedly a pet peeve of mine. And I&#8217;d like to think that the reason why <code>.live()</code> persists so sturdily when <code>.delegate()</code> is most clearly a better choice (aside from the fact that the latter was introduced one major version step later in the jQuery lifetime), is that <code>.live()</code> <strong>is so much easier to type</strong>.</p>
<p>Isn&#8217;t it? I mean look at it.</p>

<div class="wp_codebox"><table><tr id="p13079"><td class="code" id="p1307code9"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// live</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">live</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> do_backflips<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// delegate</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">delegate</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> do_backflips<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Sheer convenience.</p>
<h2>.on() and .off()</h2>
<p>Which is a big reason why I -heart heart heart- the new <code>.on()</code> and <code>.off()</code> functions in jQuery 1.7.x. It streamlines <strong>all</strong> your event handling into just two functions, whether or not you&#8217;re taking into account present or future elements.</p>
<p>If you&#8217;re not familiar, the usage for <code>.on()</code> is like this:</p>

<div class="wp_codebox"><table><tr id="p130710"><td class="code" id="p1307code10"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// for present elements</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> do_backflips<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// for future elements</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#container'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'a'</span><span style="color: #339933;">,</span> do_backflips<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><em>I&#8217;d suggest you also take a look at the official documentation for the <a href="http://api.jquery.com/on" target="_blank">on</a> and <a href="http://api.jquery.com/off" target="_blank">off</a> functions as well. Pretty spiffy.</em></p>
<p>What&#8217;s really nice is that both versions of <code>.on()</code> map to <code>.bind()</code> and <code>.delegate()</code> respectively, which has the added benefit of simplifying the question of what function to use on any given case, and cleaning up syntax. And, hey, it&#8217;s also easy and intuitive to use.</p>
<p>Additionally, <code>.live()</code> has also been deprecated as of jQuery 1.7.x. I quote:</p>
<blockquote><p>
As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live().
</p></blockquote>
<p>Frankly, one could argue that good practice is being forced down the programmers&#8217; throats. But as it plays on clear improvements on jQuery&#8217;s event model, I don&#8217;t mind that one bit.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/richardneililagan?a=JZcrD2IAtlc:aJE4vUKl18M:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/richardneililagan?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/richardneililagan?a=JZcrD2IAtlc:aJE4vUKl18M:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/richardneililagan?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/richardneililagan?a=JZcrD2IAtlc:aJE4vUKl18M:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/richardneililagan?i=JZcrD2IAtlc:aJE4vUKl18M:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/richardneililagan/~4/JZcrD2IAtlc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://richardneililagan.com/2011/12/the-understated-beauty-of-jquerys-new-on-and-off-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://richardneililagan.com/2011/12/the-understated-beauty-of-jquerys-new-on-and-off-functions/</feedburner:origLink></item>
		<item>
		<title>Using generics to reuse code for WCF services</title>
		<link>http://feedproxy.google.com/~r/richardneililagan/~3/kNQWYamCdCo/</link>
		<comments>http://richardneililagan.com/2011/12/using-generics-to-reuse-code-for-wcf-services/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 03:54:16 +0000</pubDate>
		<dc:creator>Richard Neil Ilagan</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[c#.net]]></category>
		<category><![CDATA[csharp]]></category>

		<guid isPermaLink="false">http://richardneililagan.com/?p=1299</guid>
		<description><![CDATA[<p><a href="http://richardneililagan.com/2011/12/using-generics-to-reuse-code-for-wcf-services/">Using generics to reuse code for WCF services</a> was originally published in <a href="http://richardneililagan.com">Tech+Life+Music</a>.</p><p>If you've had experience working with setting up WCF services for run-of-the-mill CRUD operations (i.e. adding new entities, getting entities, etc), you know how much of a pain in the behind it is to manually type out code designed to work with a single, specific entity (or aggregate). </p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://richardneililagan.com/2011/12/using-generics-to-reuse-code-for-wcf-services/">Using generics to reuse code for WCF services</a> was originally published in <a href="http://richardneililagan.com">Tech+Life+Music</a>.</p><p>I&#8217;m definitely a sucker for code reuse (as I&#8217;d argue <strong>all</strong> programmers should be). </p>
<p>If you&#8217;ve had experience working with setting up WCF services for run-of-the-mill CRUD operations (i.e. adding new entities, getting entities, etc), you know how much of a pain in the behind it is to manually type out code designed to work with a single, specific entity (or aggregate). If you&#8217;ve got ten entity types available across your SOA, then you might expect to write at least a service operation tailored for each of them, for each of your CRUD processes.</p>
<p>That&#8217;s, in and out of itself, 40 operations that more or less will use the same gist of code.</p>
<h2>Reusing CRUD code in WCF services</h2>
<p>While your mileage may vary (and in real-life projects, the exact same code across all your operations is significantly unlikely), I&#8217;ve had to work with this exact situation a few weeks back (spewing out <a href="http://stackoverflow.com/questions/8254026/inheriting-wcf-rest-operations" title="Inheriting WCF REST operations" target="_blank">a Stack Overflow entry</a> in the process) and the eventual solution is spiffy enough not to share.</p>
<p>For a good amount of the time, reusing code just means inheriting a base class, however, in the case of service operations, we can&#8217;t tag generic methods / classes (which we really want to use as a base class) as service contracts.</p>
<p>A great workaround, is to utilize three things in writing out your operations: an interface for the contract, a (abstract) base class for the generic methods, and another class to function as the tangible service endpoint.</p>

<div class="wp_codebox"><table><tr id="p129911"><td class="code" id="p1299code11"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&#91;</span>ServiceContract<span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">interface</span> IPersonServiceContract 
<span style="color: #008000;">&#123;</span>
    <span style="color: #008000;">&#91;</span>OperationContract<span style="color: #008000;">&#93;</span>
    <span style="color: #6666cc; font-weight: bold;">void</span> Add<span style="color: #008000;">&#40;</span>Person person<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#91;</span>OperationContract<span style="color: #008000;">&#93;</span>
    Person Get<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> id<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox"><table><tr id="p129912"><td class="code" id="p1299code12"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">// Entity is our POCO entity base class</span>
<span style="color: #0600FF; font-weight: bold;">public</span> abstract <span style="color: #6666cc; font-weight: bold;">class</span> GenericCrudService<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span> <span style="color: #0600FF; font-weight: bold;">where</span> T <span style="color: #008000;">:</span> Entity
<span style="color: #008000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">// assuming Entity Framework 4.1 CF</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Add<span style="color: #008000;">&#40;</span>T entity<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        context<span style="color: #008000;">.</span><span style="color: #0000FF;">Set</span><span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>entity<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        context<span style="color: #008000;">.</span><span style="color: #0000FF;">SaveChanges</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> T Get<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> id<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> context<span style="color: #008000;">.</span><span style="color: #0000FF;">Set</span><span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Where</span><span style="color: #008000;">&#40;</span>x <span style="color: #008000;">=&gt;</span> x<span style="color: #008000;">.</span><span style="color: #0000FF;">Id</span> <span style="color: #008000;">==</span> id<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">FirstOrDefault</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox"><table><tr id="p129913"><td class="code" id="p1299code13"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">// and this will serve as the actual endpoint</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> PersonService <span style="color: #008000;">:</span> GenericCrudService<span style="color: #008000;">&lt;</span>Person<span style="color: #008000;">&gt;</span>, IPersonServiceContract
<span style="color: #008000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">// no code necessary</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>It&#8217;s pretty handy, if you ask me. For all additional endpoints you have to create, all you have to do is write out the service contract via an interface, create the actual endpoint, and have it inherit from the contract and the <code>GenericCrudService</code> using the specific type you need.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/richardneililagan?a=kNQWYamCdCo:OmnkEhLqN-Y:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/richardneililagan?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/richardneililagan?a=kNQWYamCdCo:OmnkEhLqN-Y:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/richardneililagan?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/richardneililagan?a=kNQWYamCdCo:OmnkEhLqN-Y:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/richardneililagan?i=kNQWYamCdCo:OmnkEhLqN-Y:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/richardneililagan/~4/kNQWYamCdCo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://richardneililagan.com/2011/12/using-generics-to-reuse-code-for-wcf-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://richardneililagan.com/2011/12/using-generics-to-reuse-code-for-wcf-services/</feedburner:origLink></item>
		<item>
		<title>A compelling idea for creating strong passwords that are easy to remember</title>
		<link>http://feedproxy.google.com/~r/richardneililagan/~3/mHnuWisi_2A/</link>
		<comments>http://richardneililagan.com/2011/08/a-compelling-idea-for-creating-strong-passwords-that-are-easy-to-remember/#comments</comments>
		<pubDate>Sat, 13 Aug 2011 13:33:15 +0000</pubDate>
		<dc:creator>Richard Neil Ilagan</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[brute force attack]]></category>
		<category><![CDATA[online security]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[password strength]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://richardneililagan.com/?p=1286</guid>
		<description><![CDATA[<p><a href="http://richardneililagan.com/2011/08/a-compelling-idea-for-creating-strong-passwords-that-are-easy-to-remember/">A compelling idea for creating strong passwords that are easy to remember</a> was originally published in <a href="http://richardneililagan.com">Tech+Life+Music</a>.</p><p>One of the disadvantages of strong passwords is that they have to be really complex, and therefore, hard to remember. Or do they?</p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://richardneililagan.com/2011/08/a-compelling-idea-for-creating-strong-passwords-that-are-easy-to-remember/">A compelling idea for creating strong passwords that are easy to remember</a> was originally published in <a href="http://richardneililagan.com">Tech+Life+Music</a>.</p><p>I take my <b>online security</b> very seriously. (You should too.) That means, <a href="http://richardneililagan.com/2011/01/one-facebook-privacy-setting-you-really-should-change/" title="One Facebook privacy setting you REALLY should change" target="_blank">using HTTPS whenever possible</a>, <a href="http://richardneililagan.com/2010/11/how-easy-it-is-to-hack-your-identity/" title="How Easy It Is To “Hack” Your Identity Online (a.k.a. Why You Should Be Wary of Using Public Wi-fi)" target="_blank">being wary whenever I&#8217;m out on public wifi</a>, and, most importantly, strong passwords on every single site that you identify yourself in; your email most especially. </p>
<p>Unfortunately, one of the very real banes of strong passwords is that they&#8217;re <b>generally hard to remember</b>, primarily because they &#8220;should&#8221; be made up of a cryptic array of characters that seem to follow a rationale that the harder it is for me to recall, the harder it is to crack. I&#8217;m guilty of this myself, and I find comfort in having my passwords mimic <code>y@k3n0Ga4Ar@!ad1234</code> in every single password opportunity I come across.</p>
<p>To remedy this, <a href="http://xkcd.com/936/" target="_blank">an XKCD comic from last week</a> suggests doing something completely different from what we&#8217;ve grown accustomed of doing in order to create strong passwords that are easy to remember: pick four random words and slap them together.</p>
<p><a href="http://xkcd.com/936/" target="_blank"><img alt="A compelling idea for creating strong passwords that are easy to remember" src="http://imgs.xkcd.com/comics/password_strength.png" title="XKCD: Password Strength" class="alignnone" width="596" height="484" /></a></p>
<p>The idea has been astute enough that developer <b>Jeff Preshing</b> actually took it upon himself to <a href="http://preshing.com/20110811/xkcd-password-generator" target="_blank">create an online tool that generates passwords for you</a>, according to the XKCD strip&#8217;s specs. (Of course, it&#8217;s easy enough to get four random words without an app, but the comments on this article of Preshing&#8217;s make for good technical discussions on cryptography, information security and combinatorics.)</p>
<p>Why does this work? <b>Thomas Baekdal</b>&#8216;s article on <a href="http://www.baekdal.com/tips/password-security-usability" target="_blank">The Usability of Passwords</a> provides a very thorough discussion on the topic, and I highly recommend reading that for a complete and more accurate explanation. It does a great job of detailing the topic without getting highly technical.</p>
<p>If you&#8217;re still not convinced (and wish to stick to complex passwords), then I suggest using something like <a href="http://keepass.info/" target="_blank">KeePass</a> or <a href="https://lastpass.com/" target="_blank">LastPass</a> to help consolidate and remember your passwords in an effectively secure manner.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/richardneililagan?a=mHnuWisi_2A:LtmU0kkrFJY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/richardneililagan?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/richardneililagan?a=mHnuWisi_2A:LtmU0kkrFJY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/richardneililagan?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/richardneililagan?a=mHnuWisi_2A:LtmU0kkrFJY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/richardneililagan?i=mHnuWisi_2A:LtmU0kkrFJY:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/richardneililagan/~4/mHnuWisi_2A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://richardneililagan.com/2011/08/a-compelling-idea-for-creating-strong-passwords-that-are-easy-to-remember/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://richardneililagan.com/2011/08/a-compelling-idea-for-creating-strong-passwords-that-are-easy-to-remember/</feedburner:origLink></item>
		<item>
		<title>jQuery : How to automatically make external links open to new tabs</title>
		<link>http://feedproxy.google.com/~r/richardneililagan/~3/AJxKjtKaSM8/</link>
		<comments>http://richardneililagan.com/2011/08/jquery-open-external-links-in-new-tabs/#comments</comments>
		<pubDate>Sat, 06 Aug 2011 12:15:21 +0000</pubDate>
		<dc:creator>Richard Neil Ilagan</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[jquery code]]></category>
		<category><![CDATA[jquery how to]]></category>
		<category><![CDATA[seo]]></category>

		<guid isPermaLink="false">http://richardneililagan.com/?p=1273</guid>
		<description><![CDATA[<p><a href="http://richardneililagan.com/2011/08/jquery-open-external-links-in-new-tabs/">jQuery : How to automatically make external links open to new tabs</a> was originally published in <a href="http://richardneililagan.com">Tech+Life+Music</a>.</p><p>Wouldn't it be nice (and convenient) to have external links automatically open to new tabs? Here's a clean, effortless and functional way to use jQuery on your blog!</p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://richardneililagan.com/2011/08/jquery-open-external-links-in-new-tabs/">jQuery : How to automatically make external links open to new tabs</a> was originally published in <a href="http://richardneililagan.com">Tech+Life+Music</a>.</p><p>One of the ways you can keep readers engaged to your website content is to make sure that links to external sites open to new tabs (or windows). This way, the material they&#8217;re engaged in on your site is not erased, they can switch to the newly opened content, and eventually go back to your content (and hopefully continue what they were doing). </p>
<p>However, as websites grow and scale,  it can get a little cumbersome to keep track of all the links and manually mark each of them whether or not they open in a new tab. As a case in point, in WordPress (where it&#8217;s supposedly pretty easy to do this already), whenever you add a new hyperlink while writing a new article, you have to tick a checkbox to make it open a new tab. </p>
<p>Wouldn&#8217;t it be nice to <strong>automatically</strong> have links open in a new tab (or don&#8217;t)? With a bit of jQuery code, we can.</p>
<h2>The Code</h2>
<p>If you&#8217;re itching to jump straight to the code, then here it is, in all it&#8217;s -um- glory. Just copy and paste this into your jQuery-enabled page anywhere in between script tags.</p>

<div class="wp_codebox"><table><tr id="p127314"><td class="code" id="p1273code14"><pre class="javascript" style="font-family:monospace;">jQuery<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a[href^=&quot;http://&quot;]'</span><span style="color: #009900;">&#41;</span>
        .<span style="color: #660066;">not</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'[href*=&quot;richardneililagan.com&quot;]'</span><span style="color: #009900;">&#41;</span>
        .<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'target'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'_blank'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Make sure you substitute your own domain name for the <code>richardneililagan.com</code> in there, and you&#8217;re all good to go.</p>
<p>If you want to know how that works, read on.</p>
<h2>jQuery Magic</h2>
<p>What we want to achieve is that when a link pointing outside of our domain is clicked, the linked content is loaded in a new tab. So it&#8217;s pretty clear that we want to filter all the links in our site for all those that point outside our domain.</p>
<p>We can do that using simple jQuery selectors:</p>

<div class="wp_codebox"><table><tr id="p127315"><td class="code" id="p1273code15"><pre class="javascript" style="font-family:monospace;">    <span style="color: #006600; font-style: italic;">// assuming that our domain is RICHARDNEILILAGAN.COM</span>
    <span style="color: #003366; font-weight: bold;">var</span> external_links <span style="color: #339933;">=</span> 
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a[href^=&quot;http://&quot;]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">not</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'[href*=&quot;richardneililagan.com&quot;]'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The first selector (<code>a[href^="http://"]</code>) simply filters for all the links in our page with <code>href</code> values (the URL it links to) that start with <code>http://</code>. External links, unlike internal ones, require <code>http://</code> for them to properly work, so it&#8217;s a good filter for our purposes.</p>
<p>The second filter <code>.not('[href*="richardneililagan.com]')</code> further filters our links by removing those links that have <code>richardneililagan.com</code> (our domain) in them. We&#8217;re assuming here that when a link points to something with <code>richardneililagan.com</code> in it, then its <strong>internal</strong>.</p>
<p>Now, we actually move to making these links open in new tabs. In semantic HTML, to make a link open in a new window/tab, you just have to give it the <code>target = '_blank'</code> attribute pair. So we&#8217;re going to do just that, but by using jQuery to do it for us.</p>

<div class="wp_codebox"><table><tr id="p127316"><td class="code" id="p1273code16"><pre class="javascript" style="font-family:monospace;">    external_links.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'target'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'_blank'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>With that, all our external links should have been updated <code>target</code> attributes so that they open in new tabs.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/richardneililagan?a=AJxKjtKaSM8:Mwk6SXs4FC4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/richardneililagan?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/richardneililagan?a=AJxKjtKaSM8:Mwk6SXs4FC4:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/richardneililagan?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/richardneililagan?a=AJxKjtKaSM8:Mwk6SXs4FC4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/richardneililagan?i=AJxKjtKaSM8:Mwk6SXs4FC4:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/richardneililagan/~4/AJxKjtKaSM8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://richardneililagan.com/2011/08/jquery-open-external-links-in-new-tabs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://richardneililagan.com/2011/08/jquery-open-external-links-in-new-tabs/</feedburner:origLink></item>
		<item>
		<title>How to write a jQuery plugin</title>
		<link>http://feedproxy.google.com/~r/richardneililagan/~3/B8_r-DCSs40/</link>
		<comments>http://richardneililagan.com/2011/08/how-to-write-a-jquery-plugin/#comments</comments>
		<pubDate>Mon, 01 Aug 2011 20:46:22 +0000</pubDate>
		<dc:creator>Richard Neil Ilagan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[extending jquery]]></category>
		<category><![CDATA[how to make a jquery plugin]]></category>
		<category><![CDATA[how to write a jquery plugin]]></category>
		<category><![CDATA[jquery extend]]></category>
		<category><![CDATA[jquery plugin]]></category>

		<guid isPermaLink="false">http://richardneililagan.com/?p=1245</guid>
		<description><![CDATA[<p><a href="http://richardneililagan.com/2011/08/how-to-write-a-jquery-plugin/">How to write a jQuery plugin</a> was originally published in <a href="http://richardneililagan.com">Tech+Life+Music</a>.</p><p>Making jQuery plugins is a powerful way of making code reusable across your pages and projects. This article touches on the basics of creating functional jQuery plugins.</p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://richardneililagan.com/2011/08/how-to-write-a-jquery-plugin/">How to write a jQuery plugin</a> was originally published in <a href="http://richardneililagan.com">Tech+Life+Music</a>.</p><p><script type='text/javascript' src='http://richardneililagan.com/wp-content/uploads/2011/08/jqueryplugin.js'></script></p>
<style type='text/css'>
.sliding-box div { 
    padding:5px 10px; 
    font-family:arial,sans-serif; font-size:10pt;     
}
.sliding-box .header { font-size:12pt; background-color:#333; color:#fff; }
.sliding-box .message { background-color:#eee; }
</style>
<p>One of the questions I normally get from jQuery learners (aside from why the hell <code>.bind()</code> doesn&#8217;t work on dynamically-added HTML elements) is how to write a jQuery plugin. So for this article, I thought I&#8217;d introduce a fairly simple step-by-step walkthrough of creating a jQuery plugin that allows us to make something like this really quickly:</p>
<div id='foo'></div>
<h2>Doing this using vanilla jQuery</h2>
<p>Of course, you can pretty much do this just by using plain jQuery, just as you would do with most other jQuery functionality. Something like the following would suffice:</p>

<div class="wp_codebox"><table><tr id="p124517"><td class="code" id="p1245code17"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// yeap, I know that this code can be optimized a big deal.</span>
jQuery<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// we create two DIVs which form the two parts of our message box</span>
    <span style="color: #003366; font-weight: bold;">var</span> $header <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;div/&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'header'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Some header'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        $message <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;div/&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'message'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Some message'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// we add the click handler that makes the message slide up and down</span>
    $header.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> $message.<span style="color: #660066;">slideToggle</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fast'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// finally, we stick those two DIVs inside some other element</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#foo'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>$header<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>$message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>With something like that, you&#8217;ve pretty much managed to accomplish the same thing.</p>
<p>However, if we want to be able to reuse that piece of code on several other elements, it&#8217;d be a better idea to write out that whole jQuery logic into a plugin, so we can just call on it whenever we want.</p>
<h2>The basics of extending jQuery</h2>
<p>jQuery exposes two kinds of ways to extend it: one using the <code>$</code> namespace, and the other using <code>$.fn</code>. </p>
<p>Extending the plain <code>$</code> object allows you to define new utility functions. Adding a new utility function is as easy as just naming a new property:</p>

<div class="wp_codebox"><table><tr id="p124518"><td class="code" id="p1245code18"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// creating the &quot;say&quot; utility function</span>
$.<span style="color: #660066;">say</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>message<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">alert</span> <span style="color: #009900;">&#40;</span>message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>We can then use that much like any other function by calling <code>$.say('Bros before hoes.');</code>, and it&#8217;ll behave as you&#8217;d expect it to.</p>
<p>An arguably more powerful way of extending jQuery is extending <code>$.fn</code>, which allows you to create new functions that act on wrapped objects (like, for example, <code>.addClass()</code>). You create new wrapper methods in much the same way you create utility functions:</p>

<div class="wp_codebox"><table><tr id="p124519"><td class="code" id="p1245code19"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">fn</span>.<span style="color: #660066;">foobar</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'foobar'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Inside a new wrapper function, the <code>this</code> object is set to the jQuery wrapped set that the method was called on. So if <code>$('#foo').foobar();</code> is called, then <code>this</code> inside <code>foobar()</code> is set to <code>$('#foo')</code>. This way, you can manipulate the elements as you see fit.</p>
<p>One of the things you should make a mental note of is to return the <code>this</code> context after the function resolves, so that your new wrapper method is compatible with jQuery chaining. (That is, you can do something like <code>$('#foo').foobar().addClass('bar');</code>.)</p>
<h2>Changing our original jQuery code into a plugin</h2>
<p>Now that we&#8217;ve got the basics out of the way, it should be fairly straightforward to rewrite our code above into a bit of jQuery plugin functionality. Calling our new method <code>slidingBox()</code> and applying the necessary changes in code, we get something like:</p>

<div class="wp_codebox"><table><tr id="p124520"><td class="code" id="p1245code20"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
    $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">slidingBox</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>header<span style="color: #339933;">,</span>message<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #003366; font-weight: bold;">var</span> $header <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;div/&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'header'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span>header<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            $message <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;div/&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'message'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span>message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        $header.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> $message.<span style="color: #660066;">slideToggle</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fast'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>$header<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>$message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>With that out of the way, we can then use that just by calling something like <code>$('#foo').slidingBox('This is my header.','This is my message.');</code>. With a bit of CSS styling, you&#8217;re more or less ready to go!</p>
<p>If you want a more interactive way of demo-ing the code discussed in this article, or if you want to tinker around with ready-made code a bit, then feel free to wreak havoc on <a href='http://jsfiddle.net/richardneililagan/zmww7/5/' target='_blank'>a jsFiddle I prepared especially for this article</a>. It&#8217;s got ready jQuery code, and some CSS to boot.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/richardneililagan?a=B8_r-DCSs40:ErrNl-ofP0Y:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/richardneililagan?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/richardneililagan?a=B8_r-DCSs40:ErrNl-ofP0Y:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/richardneililagan?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/richardneililagan?a=B8_r-DCSs40:ErrNl-ofP0Y:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/richardneililagan?i=B8_r-DCSs40:ErrNl-ofP0Y:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/richardneililagan/~4/B8_r-DCSs40" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://richardneililagan.com/2011/08/how-to-write-a-jquery-plugin/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://richardneililagan.com/2011/08/how-to-write-a-jquery-plugin/</feedburner:origLink></item>
		<item>
		<title>Using jQuery $.extend() to make even more powerful cached objects</title>
		<link>http://feedproxy.google.com/~r/richardneililagan/~3/lTRcDJj3vLg/</link>
		<comments>http://richardneililagan.com/2011/07/using-jquery-extend-to-make-even-more-powerful-cached-objects/#comments</comments>
		<pubDate>Thu, 28 Jul 2011 13:41:20 +0000</pubDate>
		<dc:creator>Richard Neil Ilagan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[better coding]]></category>
		<category><![CDATA[better programming]]></category>
		<category><![CDATA[extend]]></category>
		<category><![CDATA[jquery extend]]></category>

		<guid isPermaLink="false">http://richardneililagan.com/?p=1222</guid>
		<description><![CDATA[<p><a href="http://richardneililagan.com/2011/07/using-jquery-extend-to-make-even-more-powerful-cached-objects/">Using jQuery $.extend() to make even more powerful cached objects</a> was originally published in <a href="http://richardneililagan.com">Tech+Life+Music</a>.</p><p>If you cache frequently-used elements in your jQuery code, then good for you! Want to know how to make it even better?</p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://richardneililagan.com/2011/07/using-jquery-extend-to-make-even-more-powerful-cached-objects/">Using jQuery $.extend() to make even more powerful cached objects</a> was originally published in <a href="http://richardneililagan.com">Tech+Life+Music</a>.</p><p>It&#8217;s not unusual to cache reusable components in your pages onto variables so that you don&#8217;t have to reselect / reevaluate them every single time you have to do something with them. </p>
<div style="width:468px;height:60px;padding:8px;padding-top:8px;border:1px solid #ddd;background-color:#eee;margin:0 auto;margin-bottom:15px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1801311098688743";
/* tech+life+music_in-content */
google_ad_slot = "6677749381";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<p>Let&#8217;s say I had a <code>DIV</code> element that I can append paragraphs onto. (Every) Javascript developer worth his/her salt performs some bit of namespacing to the effect of:</p>

<div class="wp_codebox"><table><tr id="p122221"><td class="code" id="p1222code21"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;foo&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #808080; font-style: italic;">&lt;!-- BLAH --&gt;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>


<div class="wp_codebox"><table><tr id="p122222"><td class="code" id="p1222code22"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> app <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
    foo <span style="color: #339933;">:</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#foo'</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This way, whenever I&#8217;d want to reference that <code>DIV</code> again, I&#8217;ll just have to call it via <code>app.foo</code>. I&#8217;m actively refraining from polluting the global namespace with a slew of variables for all the elements I want cached, and I have a ready jQuery element that doesn&#8217;t need re-selection every time I want to use it.</p>
<h2>Adding in functionality</h2>
<p>Now, say that I want to add in the functionality to actually add in the paragraphs into my <code>DIV</code>. I can achieve that by doing something like:</p>

<div class="wp_codebox"><table><tr id="p122223"><td class="code" id="p1222code23"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> addParagraph <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> myParagraph <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;p&gt;&lt;/p&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    app.<span style="color: #660066;">foo</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>myParagraph<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>&#8230; which is perfectly valid since <code>app.foo</code> is, in itself, a valid jQuery object. Improving on that a bit, I&#8217;d personally stick that function into the namespace I created prior, so that I don&#8217;t add unnecessary global objects.</p>

<div class="wp_codebox"><table><tr id="p122224"><td class="code" id="p1222code24"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> app <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
    foo <span style="color: #339933;">:</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#foo'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    addParagraph <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> myParagraph <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;p&gt;&lt;/p&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        app.<span style="color: #660066;">foo</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>myParagraph<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> 
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h2>Making it even better</h2>
<p>That&#8217;s good. But if you&#8217;re a stickler for code (as I am), you&#8217;ll probably be itching to structure the code so that <code>app.foo</code> owns the <code>addParagraph</code> function. It makes better sense to have a function that acts on an object alone to be within scope of said object. I&#8217;ve got you.</p>
<p>One way to go about it is something like :</p>

<div class="wp_codebox"><table><tr id="p122225"><td class="code" id="p1222code25"><pre class="javascript" style="font-family:monospace;">app.<span style="color: #660066;">foo</span>.<span style="color: #660066;">addParagraph</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> myParagraph <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;p&gt;&lt;/p&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>myParagraph<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>&#8230; and that on its own isn&#8217;t exactly bad, as you&#8217;re getting exactly what you want done. However, the way I&#8217;d recommend it most of the time is by using jQuery&#8217;s <code>$.extend()</code> function.</p>

<div class="wp_codebox"><table><tr id="p122226"><td class="code" id="p1222code26"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>app.<span style="color: #660066;">foo</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
    addParagraph <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> myParagraph <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;p&gt;&lt;/p&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>myParagraph<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><code>$.extend()</code> isn&#8217;t something that a lot of jQuery programmers bother with (at least, I think so), but it accomplishes more or less exactly the same thing. So why, then, should I use the <code>$.extend()</code>?</p>
<ol>
<li>
<strong>It&#8217;s cleaner and easier to add in multiple functionalities at once.</strong></p>
<p>If I wanted to add in more stuff, like add, edit and remove paragraph functionalities into my object, my code would most probably end up a mess. Not that it&#8217;s not possible, but it&#8217;s a bit of a maintainance nightmare to have to code something like</p>

<div class="wp_codebox"><table><tr id="p122227"><td class="code" id="p1222code27"><pre class="javascript" style="font-family:monospace;">app.<span style="color: #660066;">foo</span>.<span style="color: #660066;">add</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
app.<span style="color: #660066;">foo</span>.<span style="color: #660066;">edit</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
app.<span style="color: #660066;">foo</span>.<span style="color: #660066;">remove</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// ... some more functions</span></pre></td></tr></table></div>

<p>I&#8217;d rather see something like</p>

<div class="wp_codebox"><table><tr id="p122228"><td class="code" id="p1222code28"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>app.<span style="color: #660066;">foo</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
    add <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    edit <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    remove <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>&#8230; and since we&#8217;re technically working with a plain JSON object as <code>$.extend()</code>&#8216;s second parameter, it&#8217;s perfectly valid to go this path :</p>

<div class="wp_codebox"><table><tr id="p122229"><td class="code" id="p1222code29"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> paragraphFunctions <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
    add <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    edit <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    remove <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
$.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>app.<span style="color: #660066;">foo</span><span style="color: #339933;">,</span> paragraphFunctions<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Wouldn&#8217;t you agree that that&#8217;s much easier to look at and take care of?
    </li>
<li>
<strong>It&#8217;s easier to work with multiple components that share the same functionality.</strong></p>
<p>Not only is it easier to slap on multiple functionalities on one object, but it&#8217;s also easier to slap on the same functionalities onto multiple objects.</p>
<p>If I had two of those <code>DIV</code>s, then traditionally I&#8217;d have to do something like this:</p>

<div class="wp_codebox"><table><tr id="p122230"><td class="code" id="p1222code30"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> app <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
    foo <span style="color: #339933;">:</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#foo'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    bar <span style="color: #339933;">:</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#bar'</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
app.<span style="color: #660066;">foo</span>.<span style="color: #660066;">add</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
app.<span style="color: #660066;">foo</span>.<span style="color: #660066;">edit</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
app.<span style="color: #660066;">foo</span>.<span style="color: #660066;">remove</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
app.<span style="color: #660066;">bar</span>.<span style="color: #660066;">add</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
app.<span style="color: #660066;">bar</span>.<span style="color: #660066;">edit</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
app.<span style="color: #660066;">bar</span>.<span style="color: #660066;">remove</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// yeap, I know that that's kind of a stretch</span></pre></td></tr></table></div>

<p>A more convenient method would be to cache a JSON object with the common functionalities, and use <code>$.extend</code> to slap those onto the relevant components.</p>

<div class="wp_codebox"><table><tr id="p122231"><td class="code" id="p1222code31"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> paragraphFunctions <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
    add <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    edit <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    remove <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
$.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>app.<span style="color: #660066;">foo</span><span style="color: #339933;">,</span> paragraphFunctions<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>app.<span style="color: #660066;">bar</span><span style="color: #339933;">,</span> paragraphFunctions<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Of course, you could also utilize Javascript prototyping at a lower level to achieve the same thing, but this is a somewhat quicker (and less complex) way of doing that.
    </li>
</ol>
<p>You can check out a very rudimentary example of making it all work over on <a href='http://jsfiddle.net/richardneililagan/7CTn7/2/' target='_blank'>jsFiddle</a>.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/richardneililagan?a=lTRcDJj3vLg:IsThFmMdGCU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/richardneililagan?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/richardneililagan?a=lTRcDJj3vLg:IsThFmMdGCU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/richardneililagan?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/richardneililagan?a=lTRcDJj3vLg:IsThFmMdGCU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/richardneililagan?i=lTRcDJj3vLg:IsThFmMdGCU:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/richardneililagan/~4/lTRcDJj3vLg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://richardneililagan.com/2011/07/using-jquery-extend-to-make-even-more-powerful-cached-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://richardneililagan.com/2011/07/using-jquery-extend-to-make-even-more-powerful-cached-objects/</feedburner:origLink></item>
	</channel>
</rss>

