<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Nefarious Designs &#187; Thoughts</title>
	<atom:link href="http://nefariousdesigns.co.uk/tags/thoughts/feed/" rel="self" type="application/rss+xml" />
	<link>http://nefariousdesigns.co.uk</link>
	<description>Nefarious Designs is the web development agency and blog of Tim Huegdon, a web developer with over 5 years experience in the industry.</description>
	<lastBuildDate>Fri, 06 Jan 2012 21:37:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Sniff my browser: The Modernizr inadequacy</title>
		<link>http://nefariousdesigns.co.uk/archive/2011/05/sniff-my-browser-the-modernizr-inadequacy/</link>
		<comments>http://nefariousdesigns.co.uk/archive/2011/05/sniff-my-browser-the-modernizr-inadequacy/#comments</comments>
		<pubDate>Tue, 17 May 2011 11:03:47 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Web Standards]]></category>

		<guid isPermaLink="false">http://nefariousdesigns.co.uk/?p=654</guid>
		<description><![CDATA[I&#8217;m currently involved in a project to write a fairly extensive set of best practices for front-end development. Alongside myself, this project includes input from a fair cross-section of my peers in the front-end development community. These best practices will be implemented alongside a coding standard as standards for development within the organisation I work [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently involved in a project to write a fairly extensive set of best practices for front-end development. Alongside myself, this project includes input from a fair cross-section of my peers in the front-end development community. These best practices will be implemented alongside a coding standard as standards for development within the organisation I work for, and hopefully many other organisations when they are published.</p>
<p>Of all the standards that a front-end team might want to implement, those that concern the identification and graceful degradation of cross-browser feature sets can be the hardest to define.</p>
<p>With that in mind, I&#8217;ve been poking around the front-end community looking for possible solutions. By far the most common approach&#8212;and one that gains an astounding level of attention in the community&#8212;is to implement <a href="http://www.modernizr.com/">Modernizr</a>, a JavaScript feature sniffer created by <a href="http://farukat.es/">Faruk Ate?</a>, <a href="http://paulirish.com/">Paul Irish</a> and <a href="http://alexsexton.com/">Alex Sexton</a>.</p>
<p>Unfortunately, despite my respect for the developers involved, I just can&#8217;t advocate Modernizr as a solution. Let me explain why; but first, let&#8217;s revisit some concepts that are going to be quite relevant…</p>
<p><span id="more-654"></span></p>
<h2 id="the_web_standards_trifle">The web standards trifle</h2>
<p>The separation of structure, presentation, and dynamic behaviour is imperative to web standards. To that end, Andy &#8220;Malarkey&#8221; Clarke wrote a fantastic post detailing a method he liked to use to explain this fact to clients. He entitled it &#8220;<a href="http://www.stuffandnonsense.co.uk/archives/web_standards_trifle.html">the web standards trifle</a>&#8221;.</p>
<p>In Andy&#8217;s metaphor, the separation of concerns can be imagined as follows:</p>
<ol>
<li>
<p><strong>Sponge</strong></p>
<p>This layer is your content, marked-up with well structured and valid semantic HTML. This HTML provides more information about each piece of content and allows any device reading the code to output as appropriate.</p>
</li>
<li>
<p><strong>Fruity jelly</strong></p>
<p>This is your presentational layer. This separates all your presentational code into CSS, potentially allowing a user to override it with their own, or for you to serve something different based on context, e.g. a print or mobile stylesheet.</p>
</li>
<li>
<p><strong>Custard</strong></p>
<p>This is the layer that accommodates any on-page behaviours. In the world of web standards we use this layer to progressively enhance our HTML and CSS layers with more interactive magic. I&#8217;ll come back to this later.</p>
</li>
</ol>
<p>The true virtue of this divide is that the presentational (jelly) and behavioural (custard) layers can potentially be removed or overridden without affecting each other, or the content and markup beneath. This is hugely important if we want our websites to maintain client agnosticism and improve accessibility.</p>
<h2 id="progressive_enhancement">Progressive enhancement</h2>
<p>Following the publication of this article there have been several suggestions that I explain <a href="http://nefariousdesigns.co.uk/archive/2010/10/object-oriented-javascript-follow-up-part-1-method/#graceful_degradation">the difference between <em>graceful degradation</em> and <em>progressive enhancement</em></a>. Suffice to say, this is something I have covered previously in another article.</p>
<h2 id="browser_vs_feature_sniffing">Browser vs. Feature Sniffing</h2>
<p>Browser &#8220;sniffing&#8221; is the act of attempting to discern a user&#8217;s browser by some means. This &#8220;awareness&#8221; can then be used in conditional code to control output or interaction for a specific browser. This technique was used a great deal in days of yore, when browsers had very different rendering engines and didn&#8217;t all conform to web standards. However, it was only ever really required in JavaScript.</p>
<p>The old school way:</p>
<pre><code>if (document.all) {
    // IE4
    height = document.body.offsetHeight;
} else if (document.layers) {
    // NN4
    height = window.innerHeight;
} else {
    // other
    height = 0;
}
</code></pre>
<h3 id="not_a_good_solution">Not a good solution</h3>
<p>There are problems with the method used above; for one thing, it is not the most direct method of identifying a browser. However, putting that aside for the moment, there are issues even with the <em>theory</em> of browser sniffing:</p>
<p>It&#8217;s quite obvious that browser sniffing does not scale. As new browsers are released, the sniffing code will need updating.</p>
<p>To make matters worse, many manufacturers developed their browsers to identify themselves incorrectly to get around <em>legacy</em> browser sniffing code. This ultimately meant that sometimes browsers were misidentified.</p>
<p>Ultimately browser sniffing is not a good solution. If you adopt it, you will usually end up maintaining separate streams of development whenever you need to add or update features. There are ways to mitigate that pain, but what if there was a better solution?</p>
<h3 id="feature_sniffing">Feature sniffing</h3>
<p>A more scalable approach is to use object detection in JavaScript to discover if a feature is available before you use it. An example of this might be:</p>
<pre><code>if (document.querySelector) {
    element = document.querySelector(selectors);
}
</code></pre>
<p>The obvious advantage here is that it is browser agnostic; there are no assumptions as to which browser is involved at all. Using this technique, we overcome the scalability and maintenance headaches incurred through browser sniffing, and we can develop for graceful degradation from the outset.</p>
<h2 id="css_is_a_dsl_that_lacks_features">CSS is a DSL that lacks features</h2>
<p>Now, that&#8217;s all very well and good when we&#8217;re talking about JavaScript, but what happens when we need to affect the presentation layer?</p>
<p>CSS is a very simple <em>domain specific language</em> (DSL) that functions as a series of rules that override each other in a variety of ways (the cascade). There is no mechanism to detect a specific feature or a user-agent; only <a href="http://www.w3.org/TR/CSS2/media.html">media types</a> and potentially the odd CSS hack where a user-agent has imperfectly implemented an interpreter. There are also no conditionals; you just have to use the cascade to provide alternatives based on specificity or even just source order.</p>
<p>With these limitations, it is <strong>impossible</strong> to implement either browser <em>or</em> feature sniffing in CSS. This means we need to find an alternative method to affect the cascade based on the user&#8217;s feature set.</p>
<h2 id="the_modernizr_method">The Modernizr method</h2>
<p>Step in <a href="http://www.modernizr.com/">Modernizr</a>. In the words of <a href="http://www.modernizr.com/docs/">the documentation</a>:</p>
<blockquote>
<p>Modernizr aims to bring an end to the UA sniffing practice. Using feature detection is a much more reliable mechanic to establish what you can and cannot do in the current browser, and Modernizr makes it convenient for you in a variety of ways:</p>
<ol>
<li>
<p>It tests for over 20 next-generation features, all in a matter of milliseconds.</p>
</li>
<li>
<p>It creates a JavaScript object (named Modernizr) that contains the results of these tests as boolean properties.</p>
</li>
<li>
<p>It adds classes to the <code>html</code> element that explain precisely what features are and are not natively supported.</p>
</li>
</ol>
</blockquote>
<p>Following along so far? For the most part, that all seems fairly good. What&#8217;s more, Modernizr is definitely being pushed as the solution of choice amongst the front-end community:</p>
<ul>
<li><a href="http://diveintohtml5.org/detect.html">Mark Pilgrim&#8217;s Dive into HTML5 &#8220;Detection&#8221; chapter</a></li>
<li><a href="http://www.alistapart.com/articles/taking-advantage-of-html5-and-css3-with-modernizr/">Faruk&#8217;s &#8220;Taking Advantage of HTML5 and CSS3 with Modernizr&#8221; on A List Apart</a></li>
<li><a href="http://webdesignernotebook.com/css/how-to-use-modernizr/">Web Designer Notebook: How to use Modernizr</a></li>
<li><a href="http://blogs.sitepoint.com/build-an-awesome-image-gallery-with-jquery-modernizr-and-css3/">Image Gallery tutorial on Sitepoint</a></li>
</ul>
<p>So with all that in mind, let&#8217;s go back to why I will not be recommending Modernizr as a best practice:</p>
<h3 id="sniffing_css_features_with_javascript">Sniffing CSS features with JavaScript</h3>
<p>The real issue is that Modernizr uses JavaScript to do the feature sniffing. This method is absolutely fine if we were only looking to test for the features in JavaScript. However, Modernizr is marketed on its ability to detect CSS3 and HTML5 features so that you can write gracefully degrading CSS:</p>
<blockquote>
<p>Modernizr is a small and simple JavaScript library that helps you take advantage of emerging web technologies (CSS3, HTML 5) while still maintaining a fine level of control over older browsers that may not yet support these new technologies.</p>
</blockquote>
<p>If Modernizr had sold itself as a JavaScript feature sniffing solution that also detected CSS features perhaps I could be more forgiving. In that context, it would be the developers’ responsibility to use Modernizr correctly. However, since the Modernizr site and documentation are selling it <em>specifically</em> as a CSS feature sniffing solution, for primary use within CSS, the error is clearly with the Modernizr team themselves.</p>
<p>It&#8217;s all down to the final step outlined in the documentation I quoted earlier:</p>
<blockquote><p>
 It adds classes to the <code>html</code> element that explain precisely what features are and are not natively supported.
</p></blockquote>
<p>Modernizr uses JavaScript to add those classes to the <code>html</code> element; one for each of the features detected in the current browser. If we examine the generated source we see the following:</p>
<pre><code>&lt;html lang="en" dir="ltr" id="modernizr-com" class=" js flexbox canvas
canvastext webgl no-touch geolocation postmessage websqldatabase indexeddb
hashchange history draganddrop websockets rgba hsla multiplebgs backgroundsize
borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns
cssgradients cssreflections csstransforms csstransforms3d csstransitions
fontface video audio localstorage sessionstorage webworkers applicationcache
svg inlinesvg smil svgclippaths"&gt;
</code></pre>
<p>When I first saw that, I was horrified. Not only is it ridiculously cluttered, it also feels decidedly unsemantic and looks like a terminal case of <a href="http://www.sitekin.com/blogdetail/avoid_CSS_Classitis">classitis</a>. However, let&#8217;s try to be pragmatic here; it&#8217;s a means to an end, potentially a minor side-effect to a process that will win us some power in the bigger picture. In fact, it&#8217;s one step on from <a href="http://paulirish.com/2009/avoiding-the-fouc-v3/">Paul Irish&#8217;s proposed work around to the FOUC (flash of unstyled content)</a> which I&#8217;ve advocated as a reasonable fallback to marking progressively enhanced objects with an &#8220;enhanced&#8221; class.</p>
<h3 id="making_use_of_the_classes">Making use of the classes</h3>
<p>The Modernizr method allows you to assign styles based on these new classes on the document&#8217;s root element like so (example lifted from the Modernizr docs):</p>
<pre><code>button.glossy {
   background: #ccc url(gloss.png) 50% 50% repeat-x;
}
.cssgradients button.glossy {
   background: #ccc -webkit-gradient(linear, left top, left bottom,
         from(rgba(255,255,255, .4)),
         color-stop(0.5, rgba(255,255,255, .7)),
         color-stop(0.5, rgba(0,0,0, .2)),
         to(rgba(0,0,0, .1)));
}
.cssgradients button.glossy:hover {
   background-color: #fff;
}
</code></pre>
<p>Here we can see that <code>button.glossy</code> is first defined with a standard <code>png</code> as its background. The Modernizr-added <code>.cssgradients</code> class is then used to increase specificity and assign a WebKit gradient instead.</p>
<p>What happens if we approach the problem <em>without</em> the .cssgradients class:</p>
<p>CSS allows us to define a property twice in the same rule. It also contains built-in error handling that will ignore a property it doesn&#8217;t understand; so browsers that do not understand <code>-webkit-gradient()</code>, for example, will simply ignore a property that uses it. This allows us to progressively enhance our CSS like so:</p>
<pre><code>button.glossy {
   background: #ccc url(gloss.png) 50% 50% repeat-x;
   background: #ccc -webkit-gradient(linear, left top, left bottom,
         from(rgba(255,255,255, .4)),
         color-stop(0.5, rgba(255,255,255, .7)),
         color-stop(0.5, rgba(0,0,0, .2)),
         to(rgba(0,0,0, .1)));
}
button.glossy:hover {
   background-color: #fff;
}
</code></pre>
<p>However, because we can no longer target the <code>.cssgradients</code> class specifically, we cannot target the <code>button:hover</code> styles only when CSS gradients are detected. Clearly this is an issue we&#8217;ll have to find some way around and is exactly what Modernizr is attempting to solve.</p>
<p>This all seems as if Modernizr is giving us a great deal of power, however, it comes with a significant cost.</p>
<h2 id="dependency_on_javascript_is_bad">Dependency on JavaScript is bad</h2>
<p>Fellow web developer and good friend <a href="http://isolani.co.uk/">Mike Davies</a> wrote a really great article containing a good summary of <a href="http://isolani.co.uk/blog/javascript/DisablingJavaScriptAskingTheWrongQuestion#javascript-obstacles">obstacles potentially preventing JavaScript from executing</a> back in October 2010. This followed a somewhat presumptuous post by <a href="http://www.nczonline.net/">Nicholas Zakas</a> on the YDN regarding the <a href="http://developer.yahoo.com/blogs/ydn/posts/2010/10/how-many-users-have-javascript-disabled/">number of users with JavaScript disabled</a>.</p>
<p>In short, there are a large number of obstacles that can affect the execution&#8212;or even rewrite the source of&#8212;JavaScript included in your pages. Hence, dependancy on JavaScript is bad because it introduces many significant points of failure.</p>
<p>As an example of <em>why</em> dependency on JavaScript can be catastrophic, I recommend you read another of Mike&#8217;s posts on <a href="http://isolani.co.uk/blog/javascript/BreakingTheWebWithHashBangs">Gawker&#8217;s JavaScript dependent URIs and how it broke their sites quite considerably</a>. It&#8217;s worth noting that the Gawker sites have since seen the error of their ways and are <a href="http://kotaku.com/5800365/the-first-of-many-updates-to-kotakucom-design-is-live-right-now">attempting to fix the damage</a>.</p>
<h3 id="styling_dependant_on_javascript">Styling dependant on JavaScript</h3>
<p>By adding styles that are specific to classes that have been inserted with JavaScript, we are making those styles dependant on JavaScript. This means those styles will fail to apply if JavaScript itself has been disabled or, more commonly, the JavaScript file applying the classes has failed to load or execute successfully due to one of the reasons above. In essence, we may just as well add those styles with JavaScript directly because we&#8217;ve already broken the web standards separation of concerns.</p>
<p>Do we really want to remove the majority of CSS items covered by Modernizr if the Modernizr JavaScript include fails for some reason?</p>
<p>It would only be the feature-sniff-dependant CSS rules that would fail, since those classes would now be missing. Potentially this only means the loss of a few nice in-browser rendering optimisations. However, it also means there is a significant loss in the overall structure of specificity within your stylesheets, which could easily cascade unintended effects through to other elements. This could easily result in some content being styled to be unreadable, or worse, incorrectly hidden. This would be very bad indeed.</p>
<h2 id="alternative_solutions">Alternative solutions</h2>
<p>Modernizr is clearly unfit for purpose. If it were simply a JavaScript feature sniffing library for use <em>only</em> in JavaScript, it would be a suitable solution although only really useful for JavaScript progressive enhancement.</p>
<p>With that in mind, what other options are available that allow us to target our CSS?</p>
<h3 id="server_side_browser_sniffing">Server-side browser sniffing</h3>
<p>We could browser sniff on the server and add a class to the <code>html</code> element as we generate the HTML that is delivered in the HTTP response. This could result in something like the following:</p>
<pre><code>&lt;html lang="en" dir="ltr" class="firefox"&gt;
</code></pre>
<p>This means we can target CSS with the <code>.firefox</code> class in much the same way that we used the feature classes that Modernizr provided. There is no way for us to perform feature sniffing on the server; the best we could offer is a feature lookup based on the user-agent string that we&#8217;ve used to sniff the browser, but that would ultimately still be browser sniffing.</p>
<p>In fact, the best browser sniffing solution would allow us a little more flexibility on browser versions:</p>
<pre><code>&lt;html lang="en" dir="ltr" class="moz ff ff3-6"&gt;
</code></pre>
<p>Note I&#8217;ve added several classes this time; one for the rendering engine, one for the browser, and one that contains the major and minor versions. This would allow us more specificity.</p>
<p style="padding:10px;background:#fee;border:1px solid #c00;"><strong>Update:</strong> Matthew Pennell has written an interesting post on <a href="http://www.thewatchmakerproject.com/blog/no-more-css-hacks-browser-sniffing-with-htaccess/">server-side browser sniffing with .htaccess and environment variables</a>. Definitely worth a read.</p>
<h4 id="cache_issues">Cache issues</h4>
<p>However, server-side browser sniffing means that you&#8217;ll run into issues if your pages are publicly cacheable. This server-side solution results in a different HTTP response (the HTML) for each differing browser.</p>
<p>If you utilise any intermediary caching (<a href="http://www.squid-cache.org">Squid</a>, <a href="http://www.varnish-cache.org">Varnish</a>, or a custom origin CDN) for static pages, and you use server-side browser detection, you need to make sure those caches don&#8217;t inadvertently send the wrong content to the wrong browser. To do this you&#8217;ll need to <code>Vary: User-Agent</code> header in the HTTP response. This instructs any intermediary caches to store multiple copies of the page (one for each <code>User-Agent</code> string that it sees) and to inspect the incoming <code>User-Agent</code> string when looking for cached responses to the current request.</p>
<h3 id="ie_targeting_with_conditional_comments">IE targeting with conditional comments</h3>
<p>If we&#8217;re entirely honest with ourselves as web developers, we can probably admit that the majority of woes we experience in CSS are as a direct result of features that any given version of Internet Explorer has not implemented. In fact, I regularly interview developers who advocate maintaining a separate stylesheet for IE that is included through the use of IE&#8217;s conditional comments. Having attempted to use this method in the past, I can confidently say that it is a maintenance nightmare and quickly becomes pretty unmanageable.</p>
<p>A better technique would be to adopt conditional comments to add IE specific classes in much the same way we have with Modernizr or server-side browser sniffing. This method was first proposed by none other than Paul Irish back in 2008 in his article &#8220;<a href="http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/">Conditional stylesheets vs. CSS hacks? Answer: neither</a>&#8220;. With that method, our <code>html</code> element would look like this:</p>
<pre><code>&lt;!--[if IE ]&gt;
&lt;html lang="en" dir="ltr" class="ie"&gt;
&lt;![endif]--&gt;
&lt;!--[if !IE]&gt;--&gt;
&lt;html lang="en" dir="ltr"&gt;
&lt;!--&lt;![endif]--&gt;
</code></pre>
<p>This looks a bit odd, and often (for the true markup perfectionist) takes a bit of getting used to. However, it does give us what we need without requiring JavaScript or multiple cache versions.</p>
<p>We can even make it more specific if we so desire:</p>
<pre><code>&lt;!--[if lt IE 7 ]&gt;
&lt;html lang="en" dir="ltr" class="ie ie6"&gt;
&lt;![endif]--&gt;
&lt;!--[if IE 7 ]&gt;
&lt;html lang="en" dir="ltr" class="ie ie7"&gt;
&lt;![endif]--&gt;
&lt;!--[if IE 8 ]&gt;
&lt;html lang="en" dir="ltr" class="ie ie8"&gt;
&lt;![endif]--&gt;
&lt;!--[if IE 9 ]&gt;
&lt;html lang="en" dir="ltr" class="ie ie9"&gt;
&lt;![endif]--&gt;
&lt;!--[if gt IE 9]&gt;
&lt;html lang="en" dir="ltr" class="ie"&gt;
&lt;![endif]--&gt;
&lt;!--[if !IE]&gt;&lt;!--&gt;
&lt;html lang="en" dir="ltr"&gt;
&lt;!--&lt;![endif]--&gt;
</code></pre>
<p>Quite clearly this gets ever uglier, but the solution is entirely encompassed in the structural layer; we will always have the correct class, even if CSS or JavaScript are unavailable for some reason. We also have the same markup regardless of user-agent string, which means caching is not a problem.</p>
<p>The only flaw with this solution is that we can only target versions of Internet Explorer. No other browser implements conditional comments.</p>
<h3 id="use_css_properly_and_make_use_of_the_cascade">Use CSS properly and make use of the cascade</h3>
<p>As previously stated, CSS is designed to cascade. This means the built-in error handling will ignore properties the interpreter does not understand, and we can override rules based on specificity and source order. In most cases, these key features are more than adequate to develop gracefully degrading stylesheets.</p>
<p>Most capable front end developers are already doing this and coping just fine. Add this to the previous IE targeting approach and you&#8217;ll find that you do not need to over-engineer a solution.</p>
<h2 id="in_summary">In summary</h2>
<p>So, in summary then, I absolutely cannot recommend implementing Modernizr as a best practice for front end development. It attempts to solve a problem from the wrong direction, and introduces a new potential point of failure. What&#8217;s more it breaks the fundamental ethic of web standards; the separation of concerns.</p>
<p>I continue to recommend well crafted, gracefully degrading CSS, backed up by conditional commented classes on the <code>html</code> element for targeting IE.</p>
<p>Modernizr may still be a worthy solution for JavaScript-only feature sniffing, if only it allowed the developer to disable the injection of classes on the <code>html</code> element.</p>
]]></content:encoded>
			<wfw:commentRss>http://nefariousdesigns.co.uk/archive/2011/05/sniff-my-browser-the-modernizr-inadequacy/feed/</wfw:commentRss>
		<slash:comments>44</slash:comments>
		</item>
		<item>
		<title>Object-oriented JavaScript follow up part 2: Technical</title>
		<link>http://nefariousdesigns.co.uk/archive/2010/10/object-oriented-javascript-follow-up-part-2-technical/</link>
		<comments>http://nefariousdesigns.co.uk/archive/2010/10/object-oriented-javascript-follow-up-part-2-technical/#comments</comments>
		<pubDate>Thu, 28 Oct 2010 13:12:52 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Reference]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Web Standards]]></category>

		<guid isPermaLink="false">http://nefariousdesigns.co.uk/?p=556</guid>
		<description><![CDATA[Following on from part 1 of my follow-up to “Object-oriented JavaScript”, part 2 provides a technical update to some of the theories and examples. Without further a-do, let’s jump in with the technical stuff: A quick note on variable declaration The var declaration allows you to chain definitions in a comma separated list; what’s more [...]]]></description>
			<content:encoded><![CDATA[<p>Following on from <a href="http://nefariousdesigns.co.uk/archive/2010/10/object-oriented-javascript-follow-up-part-1-method/">part 1 of my follow-up to “Object-oriented JavaScript”</a>, part 2 provides a technical update to some of the theories and examples.</p>
<p>Without further a-do, let’s jump in with the technical stuff:</p>
<p><span id="more-556"></span></p>
<h2 id="a_quick_note_on_variable_declaration">A quick note on variable declaration</h2>
<p>The <code>var</code> declaration allows you to chain definitions in a comma separated list; what’s more that list can reference variables declared earlier in <em>the same list</em>.</p>
<p>Take this code as an example:</p>
<pre><code>var el = document.getElementById(“my-element”);
var elWidth = el.offsetWidth;
var elHeight = el.offsetHeight;
var elArea = elWidth * elHeight;
</code></pre>
<p>This could alternatively be written like so:</p>
<pre><code>var el = document.getElementById(“my-element”),
    elWidth = el.offsetWidth,
    elHeight = el.offsetHeight,
    elArea = elWidth * elHeight;
</code></pre>
<p>Personally, I prefer the latter method simply because it keeps my <code>var</code> declarations in one place (where possible) without endless repetition of the <code>var</code> keyword. However, this is simply a minor note on coding style, rather than something that can improve the operation of your code.</p>
<h2 id="understanding_object_oriented_scope">Understanding object-oriented scope</h2>
<p>As any experienced JavaScript coder knows, JavaScript is functionally scoped; this means any variables created within an object or function are only available within that object or function.</p>
<p>Simple, right?</p>
<p>Well no, there are actually a couple of complications to this behaviour that you should really understand:</p>
<h3 id="passing_by_reference">Passing by reference</h3>
<p>When passing arguments in JavaScript, it’s not immediately clear how those arguments are being handled internally. In fact, it is entirely dependant on the data-type of those arguments.</p>
<p>When passing arguments of type Number, String, or Boolean, JavaScript will pass them in <em>by value</em>. This means that the value stored in the argument will actually be a copy of the original value:</p>
<pre><code>function accidentalFall(count) {
    count = count - 1; // Remove one
}

var greenBottles = 10;

alert(greenBottles); // greenBottles is 10

accidentalFall(greenBottles); // Pass by value

alert(greenBottles); // greenBottles still 10
</code></pre>
<p>Passing in an object, however, passes the argument <em>by reference</em>. This means that, within the function, the argument is not a copy, but a reference&#8212;or link, if you like&#8212;to the original object. This means any members of that object are available within our function, and any changes to the object passed as an argument will be reflected <em>outside of the scope</em> of the function.</p>
<p>Actually, the way JavaScript handles references is another blog article in itself. Watch this space.</p>
<p>Here’s our example again:</p>
<pre><code>function accidentalFall(obj) {
    obj.count = obj.count - 1; // Remove one
}

var greenBottles = {
    count: 10
};

alert(greenBottles.count); // 10

accidentalFall(greenBottles); // Pass by reference

alert(greenBottles.count); // 9
</code></pre>
<p>This is a subtle difference, but one, I think you’ll agree, that is important to understand.</p>
<h3 id="the_this_special_operator">The <code>this</code> special operator</h3>
<p>The <code>this</code> operator can be used to obtain a reference to the current context object and allows properties and methods within that execution context to be referenced. The context object can be considered a “hidden” parameter that is passed to any function.</p>
<p>There are four ways the context is made available to a function:</p>
<h4 id="implicitly_with_a_method">Implicitly with a method</h4>
<pre><code>var myObject.method = function(arg1, arg2…) {
    // Context here is myObject, and has been passed
    // implicitly.
}
</code></pre>
<h4 id="implicitly_with_new">Implicitly with <code>new</code></h4>
<pre><code>var myConstructor = function(arg1, arg2…) {
    // Here we have a new anonymous context
    // understandable as the instance…
}
// …so the context here will be myObj
var myObj = new myConstructor(arg1, arg2…);
</code></pre>
<h4 id="explicitly_with_functioncall">Explicitly with <code>Function.call</code></h4>
<pre><code>var myObject.method = function(arg1, arg2…) {
    // Implicit context is myObject
}
// Explicitly force context to anotherObject
myObject.method.call(anotherObject, arg1, arg2…);
</code></pre>
<h4 id="explicitly_with_functionapply">Explicitly with <code>Function.apply</code></h4>
<pre><code>var myObject.method = function(arg1, arg2…) {
    // Implicit context is myObject
}
// Explicitly force context to anotherObject
myObject.method.apply(anotherObject, [arg1, arg2…]);
</code></pre>
<p>In general, JavaScript developers tend to rely on <em>implicit</em> context passing rather than <em>explicit</em>. However, there is one situation where this reliance falls down…</p>
<h3 id="a_common_problem">A common problem</h3>
<p>When registering event handlers against DOM nodes in JavaScript, the <code>this</code> context no longer references the method’s parent object, but rather the DOM node to which the event handler is registered.</p>
<p>The easiest way around this is to make sure the reference to the context object originally stored in <code>this</code> is maintained before defining the event handler:</p>
<pre><code>var widget.init = function () {
    var myButton = document.getElementById(“my-button”),
        counter = 0,
        that = this;

    myButton.onClick = function(event) {
        that.counter++;
        this.innerHTML = “Clicked!”;
    }
}
</code></pre>
<p>Further to this, according to Douglas Crockford, there is an error in the ECMAScript spec. that causes <code>this</code> to be set incorrectly for inner functions; something that he discusses in his article <a href="http://www.crockford.com/javascript/private.html">Private Members in JavaScript</a>:</p>
<pre><code>function Container(param) {
    function dec() {
        if (secret &gt; 0) {
            secret -= 1;
            return true;
        } else {
            return false;
        }
    }

    this.member = param;
    var secret = 3;
    var that = this;

    this.service = function () {
        if (dec()) {
            return that.member;
        } else {
            return null;
        }
    };
}
</code></pre>
<p>Now, the &#8220;<code>var that = this</code>&#8221; technique is certainly a bone of contention amongst members of the JavaScript community, but I’m firmly on the fence in the whole discussion. Certainly my second example could be solved with a complex network of <code>Function.call</code> and <code>Function.apply</code> instead of <code>that.member</code>, but my first example would be somewhat more difficult.</p>
<p>Personally, I feel if Doug Crockford&#8212;a developer with many years more experience and infinitely more JS knowledge than myself&#8212;says it’s ok, then I’m fine with it.</p>
<h2 id="garbage_collection">Garbage collection</h2>
<p>As JavaScript is a scripting language, it implicitly allocates memory for objects, strings, variables, and so on as it runs. <em>Garbage collection</em> is the process by which the JavaScript engine detects when those pieces of memory are no longer reachable&#8212;that is, they could not possibly ever be used again&#8212;and reclaims the memory.</p>
<p>The ECMAScript specification (of which JavaScript is an implementation) doesn’t include a definition on how a JS engine should handle garbage collection, so although each JavaScript engine includes garbage collection&#8212;memory usage would quickly snowball if they didn’t&#8212;they all handle it somewhat differently.</p>
<p>Some engines are better than others; Google’s V8 is exceptionally good, where as the IE JScript engine is notoriously bad (often resulting in memory leaks).</p>
<h2 id="closures">Nested functions and closures</h2>
<p>JavaScript allows the nesting of functions, creating nested scope blocks that inherit scope from their parents all the way up to the global scope.</p>
<p>Take this code for example (there are much better ways of doing this; this method is only in the interests of illustration):</p>
<pre><code>function appendList(list, itemPrefix) {
    var getListItem = function(x) {
        return document.getElementById(itemPrefix + x);
    }

    for (var i = 0, j = list.length; i &lt; j; i++) {
        getListItem(i).innerHtml += ‘ [done]’;
    }
}
</code></pre>
<p>In the above example <code>getListItem</code> is a nested function within <code>appendList</code>. This means it inherits everything within the scope of <code>appendList</code>. As a result of this, the inner function is able to make use of the <code>itemPrefix</code> parameter that is passed to its parent without it needing to be passed in as another parameter on <code>getListItem</code>.</p>
<p>When JS automatically garbage collects the <code>appendList</code> function, it will find no <em>external</em> references to the <code>getListItem</code> function and will garbage collect that as well.</p>
<p>This is a useful feature of JavaScript, and allows for fairly advanced l<a href="http://stackoverflow.com/questions/16501/what-is-a-lambda-function">ambda functions</a> (anonymous functions), as well as providing a useful tool for namespacing library functions.</p>
<p>However, if, upon garbage collection, JavaScript finds an external reference to a nested function, it creates a closure of scope; thus maintaining access to all the variables required within the scope of that function.</p>
<p>This is known as <strong>a closure</strong>.</p>
<h3 id="common_usage">Common usage of closures</h3>
<p>The most common occurrence of a closure in JavaScript is when declaring event callbacks. This is simply due to the fact that the callback function is referenced within the event listener once registered.</p>
<p>However, it’s important to understand that many modern libraries, plugin architectures, and plugins themselves also make use of closures, and understanding <em>how</em> they use them can mean the difference between controlled and uncontrolled memory usage.</p>
<h3 id="invisible_pitfalls_are_invisible">Invisible pitfalls are invisible</h3>
<p>It’s obvious when you think about it, but all closures have a potentially high memory imprint as they are maintaining much more than just their constituent parts. What’s more, because of their inherent avoidance of garbage collection, they are maintained until they are manually destroyed either by the code, or by a page refresh.</p>
<h2 id="prototypal_inheritance">Prototypal inheritance</h2>
<p>I did discuss prototypal inheritance in <a href="http://nefariousdesigns.co.uk/archive/2006/05/object-oriented-javascript/">my original Object-Oriented Javascript article</a>, however I just want to go into a little more detail here.</p>
<p>In a prototypal system, objects are supposed to inherit from objects; unlike in a <em>classical inheritance</em> system where classes inherit from classes and <em>instantiate</em> objects. JavaScript has no class (pun intended).</p>
<p>Prototypal inheritance is actually simpler than classical inheritance once you get your head around it. You don&#8217;t need to define classification, so your code is smaller and less redundant since objects inherit from other more general objects. It is a model of <a href="http://en.wikipedia.org/wiki/Differential_inheritance"><em>differential inheritance</em></a>; i.e. each level of inheritance only adds the differences with its parent.</p>
<p>Unfortunately, JavaScript is a bit confused about its prototypal nature, and wants to fit in with the other scripting languages by pretending to like The Beatles and by making itself more attractive to classically trained programmers by introducing the <code>new</code> operator.</p>
<p>This means that:</p>
<pre><code>new myConstructor();
</code></pre>
<p>produces an object that inherits from <code>myConstructor.prototype</code>.</p>
<p>This indirection means that JavaScript actually has a pretty ugly constructor pattern and most new JavaScript developers never really get to grips with the inheritance model at all.</p>
<p>However, all that has changed with the all singing, all dancing advent of JavaScript 1.8.5 (The New Shit™), which introduces the <code>Object.create</code> method:</p>
<pre><code>var human = {
    legs: 2,
    arms: 2
};

var tim = Object.create(human, {
    tall: true,
    fat: true,
    overInflatedSenseOfSelfImportance: true
});
</code></pre>
<p>Mmm tasty, but since JS 1.8.5 only seems to be implemented in Firefox 4 (still in beta), don’t get all excited just yet.</p>
<p>If you want something similar in your own code, you can implement the following for a similar approach (and still kiss goodbye to ever having to use the <code>new</code> operator again):</p>
<pre><code>if (typeof Object.inherits !== 'function') {
    Object.inherits = function(parent, child) {
        function temp() {};
        temp.prototype = parent.prototype;
        child.super_ = parent.prototype;
        child.prototype = new temp();
        child.prototype.constructor = child;
    };
}

Object.inherits(parentConstructor, childConstructor);
</code></pre>
<p>What’s more, this DIY version will allow you access to any superclass’ implementations of a particular method like so:</p>
<pre><code>childConstructor.prototype.foo = function(a) {
    // Here’s some of that scope correction we discussed
    // earlier…
    childConstructor.super_.foo.call(this, a);

    // Other code
};
</code></pre>
<p>This code is a mix of the <code>goog.inherits</code> function&#8212;included in the Closure library&#8212;and the <code>Object.create</code> outline by Crockford in his <a href="http://javascript.crockford.com/prototypal.html">article on prototypal inheritance</a>.</p>
<h2 id="javascript_design_patterns">JavaScript design patterns</h2>
<p>Taking all this into account, we can start developing some incredibly useful design patterns that make use of prototypal inheritance, closures, and JavaScripts nuances of scope.</p>
<p>In fact, several have already been developed within the JavaScript community:</p>
<h3 id="javascript_namespacing">JavaScript namespacing</h3>
<p>To avoid the perils of globally scoped variables and functions, it is advisable to create a single global object for the purposes of namespacing the rest of your code. This is relatively simple to achieve:</p>
<pre><code>var NEF = window.NEF || {};
</code></pre>
<p>This command tests for the existence of a <code>NEF</code> object at the global scope, and if evaluated to true, returns that object. Otherwise, it creates a new object using the object literal syntax.</p>
<p>You may now assign any further variables or modules to your namespace:</p>
<pre><code>NEF.myAttribute = ‘foo’;
NEF.myFunction = function() {
    …
};</code></pre>
<h3 id="module_pattern">Module pattern</h3>
<p>The JavaScript module pattern was first proposed by Doug Crockford as a means of enforcing public and private object members through the use of closures.</p>
<p>My preferred variation on the pattern is such:</p>
<pre><code>NEF.Module = function() {
    // Private members
    var privateAttribute;

    function privateMethod() {
        alert('Private method called.');
    }

    var pub = {
        // Public members
        publicAttribute: true,

        publicMethod: function() {
            // Private members are in scope here

            privateMethod();

            // Public members are addressable through the 'pub' object.

            pub.publicAttribute = false;
        }
    }

    return pub;
}();
</code></pre>
<p>This method simple uses a closure to maintain private variables in the scope of the returned <code>pub</code> object. The trick of this technique is the use of the <code>()</code>, right at the end of the code, after the parent function definition, which causes the function to run immediately and return the <code>pub</code> object.</p>
<h3 id="jquery_plugins">jQuery plugins</h3>
<p>The jQuery plugin architecture also makes use of closures to do something quite similar to the Module Pattern above. However, jQuery plugins are specifically namespaced to the jQuery object itself:</p>
<pre><code>(function($) {
    // Private members
    var debugMode = false;

    function debug(msg) {
        if (!debugMode) { return; }
        if (window.console &#038;&#038; window.console.log){
            window.console.log(msg);
        } else {
            alert(msg);
        }
    }

    $.fn.extend({
        myPlugIn: function(config) {
            var defaults = {
                …
            };

            if (config) {
                $.extend(defaults, config);
            }

            this.each(function() {

            });

            return this;
        },

        publicMethod: function() {
            …
        }
    });
})(jQuery);
</code></pre>
<p>Alternatively, should you wish to only include a single public method, you can avoid <code>jQuery.fn.extend</code> by instead making use of <code>jQuery.fn</code> for definition:</p>
<pre><code>(function($) {
    // Private members
    var debugMode = false;

    function debug(msg) {
        if(debugMode &amp;&amp; window.console &amp;&amp; window.console.log){
            window.console.log(msg);
        } else {
            alert(msg);
        }
    }

    $.fn.myPlugIn = function(config) {
        var defaults = {
            …
        };

        if (config) {
            $.extend(defaults, config);
        }

        this.each(function() {

        });

        return this;
    };
})(jQuery);
</code></pre>
<p>In this code we can see that jQuery is passed to an anonymous function, that is run immediately, as the parameter <code>$</code>. The anonymous function provides a scope block for the plug-in code, thus preventing potential headaches from variable naming clashes across shared code. The plug-in functions themselves are then created as closures so that they have access to the private variables and functions within that outer anonymous function. These plug-in variables are then bound to the passed in jQuery instance <code>$</code> using jQuery’s own built in extension functions.</p>
<p>This is actually quite a clever use of closures, although it does have the potential for memory leaks and excessive memory usage if variables and references aren’t kept in check. With that in mind, it’s often a very good idea to profile your jQuery plugins to understand what might need tidying up.</p>
<h3 id="custom_events">Custom events</h3>
<p>Most modern JavaScript libraries include a mechanism for defining your own custom events. A custom event is merely a bespoke event, defined in your code, that other event-handler functions may be bound to. This custom event may then be triggered by you at any given point of execution in the code.</p>
<p>The custom event architecture is an implementation of the Observer Pattern, in which an object maintains a list of dependant “observers” which it notifies automatically of any state changes. In JavaScript, the object maintaining the list is our event, and the “observers” are the event handlers.</p>
<p>Using custom events in your own code provides a useful binding for other developers’ code. The event itself is loosely coupled to the event handlers, thus, <em>additional</em> event handlers can be added or removed by third-party code.</p>
<p>For more information on custom events, I’d recommend having a look at the documentation for the library of your choice. Here are few links:</p>
<ul>
<li><a href="http://api.jquery.com/bind/">jQuery custom events: .bind()</a></li>
<li><a href="http://developer.yahoo.com/yui/event/#customevent">YUI2 custom events: The CustomEvent object</a></li>
<li><a href="http://www.yahooapis.com/yui/3/event/#customevent">YUI3 custom events</a></li>
</ul>
<h2 id="summary">Summary</h2>
<p>So that’s the technical addendum to my 2006 post. Hopefully, that should serve to bring the article up to date, and correct a few of my previous errors. As always, comments and corrections are welcome via the comment form below.</p>
<p>Originally I had intended posting this article in two parts, however, it has continued to grow even as I write it. For this reason, the third and final part of this follow-up series will look at what’s on the horizon for JavaScript development, including how GoogleBot deals with JavaScript, the importance of supporting a core experience (where JavaScript is unavailable), server-side JavaScript, and architecting JavaScript applications.</p>
]]></content:encoded>
			<wfw:commentRss>http://nefariousdesigns.co.uk/archive/2010/10/object-oriented-javascript-follow-up-part-2-technical/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Object-Oriented JavaScript Follow-Up Part 1: Method</title>
		<link>http://nefariousdesigns.co.uk/archive/2010/10/object-oriented-javascript-follow-up-part-1-method/</link>
		<comments>http://nefariousdesigns.co.uk/archive/2010/10/object-oriented-javascript-follow-up-part-1-method/#comments</comments>
		<pubDate>Fri, 08 Oct 2010 08:43:08 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Reference]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Web Standards]]></category>

		<guid isPermaLink="false">http://nefariousdesigns.co.uk/?p=541</guid>
		<description><![CDATA[Back in May, 2006, I wrote an article entitled Object Oriented JavaScript. It was an exercise in both writing a useful tutorial, and a brain-dump of various things I had learned about writing object-oriented code on the client side. It quickly became apparent&#8212;as the article was linked to from a multitude of my favourite web [...]]]></description>
			<content:encoded><![CDATA[<p>Back in May, 2006, I wrote an article entitled <a href="http://nefariousdesigns.co.uk/archive/2006/05/object-oriented-javascript/">Object Oriented JavaScript</a>. It was an exercise in both writing a useful tutorial, and a brain-dump of various things I had learned about writing object-oriented code on the client side. It quickly became apparent&#8212;as the article was linked to from a multitude of my favourite web standards development sources&#8212;that the tutorial itself was helpful; the comments burgeoned, and the traffic rocketed.</p>
<p>When I read that article now, however, it bothers me. The tutorial is still good although the information within is somewhat dated; and my personal experience, knowledge, and general approach to writing JavaScript has changed quite drastically. The fact that the article still receives a consistently high number of unique visitors on a daily basis, when I no longer agree with all the content within it, bothers me even more. With that in mind, I have decided to write an update that looks at OOJS as I would currently use it.</p>
<p>The resulting post has become quite extensive, so I’ve decided to split it into two separate articles. This first one will cover some development theory, whilst the second will dive into JavaScript coding specifics.</p>
<p><span id="more-541"></span></p>
<h2 id="a_note_on_the_name">A note on the name</h2>
<p>A friend of mine recently quoted this little gem in his Twitter stream:</p>
<blockquote>
<p>Java is to JavaScript as Ham is to Hamster.</p>
</blockquote>
<p>Enough said.</p>
<h2 id="is_it_object_oriented">Is it object-oriented?</h2>
<p>In my original article I stated that JavaScript was <em>not</em> an object-oriented language, but rather an object-<em>based</em> language. This was entirely unfair on JavaScript, and I&#8217;d like to fix that:</p>
<p>JavaScript <em>is</em> an object-oriented language. However, it breaks away from more conventional object-oriented languages by implementing prototypal inheritance, instead of classical inheritance. This is a Very Good Thing™ (although that seems to be a matter of opinion). More on that later.</p>
<h2 id="first_principles_for_javascript_programming">First principles for JavaScript programming</h2>
<p>Before I start, let me be clear that there are first principles of programming that are language agnostic. We’re going to look at a couple of those, but I’d also like to discuss a few of the more JavaScript specific principles first; those that relate to the cross-browser web standards environment. Finally, I’m aware that I’m really only scratching the surface of some of these topics. I don’t really want to muddy the water here by waxing lyrical on good development practices, so if you’re after more depth, I’d recommend researching them via the search engine of your choice:</p>
<h3 id="proper_separation_of_the_behavioural_layer">Proper separation of the behavioural layer</h3>
<p>Above everything else, it’s important to keep your content and markup (HTML), presentation (CSS), and behavioural (JavaScript) layers separate. Why is that important? Well if one or more of those layers are missing or broken (with the obvious exception of the core HTML), the others should still function as intended. Ultimately this makes presentation and behaviour optional, and a user might turn them off&#8212;via their browser settings&#8212;should they so desire. Alternatively, the user may include custom presentation or behaviour to aid a particular use-case.</p>
<p>In JavaScript, proper separation requires making use of the DOM to bind behaviour to HTML elements via element identifiers (i.e. the <code>id</code> or <code>class</code> attribute) in your source code. The alternative would be to write JS directly into the HTML, via event attributes such as <code>onClick=””</code> or via the <code>javascript:</code> pseudo-protocol in the <code>href</code> attribute. This is not a good practice and I heartily recommend against it.</p>
<h3 id="graceful_degradation">Graceful degradation</h3>
<p>Graceful degradation is a well known software engineering concept which involves writing your code to take advantage of awesome feature X, unless awesome feature X is unavailable, in which case degrade to use slightly-less-awesome feature Y (assuming that too is available).</p>
<p>In web development terms this might mean making use of an amazing JavaScript date picker widget on a text-based input box, and just degrading to server-side date validation if JS is not turned on in the browser. It could also mean making use of the latest CSS3 styling techniques but degrading to use CSS2 techniques in less capable browsers.</p>
<p>In short; build everything in the most up to date browser, making use of all it’s wonderful modern features, and then go back and make sure the site is still usable when any of those features are not.</p>
<p>The problem with approaching the issue from this direction, however, is that you are saying to your users: “You (or your browser) are incapable of handling the full experience we want to present, so here’s a cut-down version.” This pretty much flies in the face of user-centric design, and good user experience. With that in mind, we’d be better using…</p>
<h3 id="progressive_enhancement">Progressive enhancement</h3>
<p>Progressive enhancement involves approaching the problem from the other direction. You should design for the user-agent with the least capabilities and add functionality for more capable browsers afterwards.</p>
<p>In web terms this means developing and designing with nothing but the base features of HTML in mind, and then enhancing those features (or the features of the browser interpreting that HTML) by attaching CSS and JS to the HTML via element identifiers like IDs and classes.</p>
<p>The final outcome of these two approaches might be very similar, but the subtle difference is that you are giving more attention to the less capable user-agent when you progressively enhance.</p>
<p>The most common use-case for progressive enhancement is the support of a non-JS experience.</p>
<h3 id="dry_dont_repeat_yourself">DRY (Don’t Repeat Yourself)</h3>
<p>Every piece of knowledge must have a single, unambiguous, authoritative representation within a system. This means abstracting code into shared functions and objects whenever you find you are repeating yourself, and attempting to maintain a single source of truth in every aspect of your system.</p>
<p>DRY is a well known paradigm in software engineering, and as such, should be applied in every detail of your JavaScript code.</p>
<h3 id="refactor_early_refactor_often">Refactor early, refactor often</h3>
<p>Further to the principle of DRY, it is important that if you spot a potential issue in your JavaScript code you fix it. The more small refactors you do, the less time-consuming big refactors you are likely to need to do later on.</p>
<p>Once you’re refactoring often, you’ll be able to…</p>
<h3 id="make_it_work_make_it_right_make_it_fast">Make it work, make it right, make it fast</h3>
<p>The first iteration of your code should only look to reach the level of functionality defined in the functional specification. Once this has been achieved, refactor to improve the <em>way</em> it works&#8212;so the code is “right” in your opinion. This may very well mean a complete overhaul of architecture, but you will be able to concentrate much more specifically on that since you already have it working. The final stage in this development cycle is to optimise your code for performance and efficiency; premature optimisation is a fundamental mistake in development.</p>
<h3 id="useful_resources">Useful resources</h3>
<p>When it comes to general development, there are a veritable plethora of resources out there, but my recommended starting point is the book <a href="http://www.amazon.co.uk/gp/product/020161622X?ie=UTF8&amp;tag=gamersite-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=020161622X"><strong>The Pragmatic Programmer</strong>, by Andrew Hunt and David Thomas</a>. This book outlines quite a few paradigms that should get you thinking about the way you develop.</p>
<h2 id="important_things_to_understand">Important things to understand</h2>
<h3 id="pure_javascript">Pure JavaScript</h3>
<p>In this age of JavaScript libraries and frameworks, it’s important to make sure you understand core JavaScript functions, objects, and methods. Although your library of choice may clean up any cross-browser issues you may encounter, it is always important to understand exactly how you are interacting with JavaScript as a language.</p>
<h4 id="useful_resources2">Useful resources:</h4>
<p>The <a href="http://developer.mozilla.org/en/JavaScript">Mozilla Developer Centre section on JavaScript</a> is an invaluable reference resource when writing pure JavaScript. Also, make sure you own a copy of <a href="http://www.amazon.co.uk/gp/product/0596101996?ie=UTF8&amp;tag=gamersite-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=0596101996"><strong>JavaScript: The Definitive Guide</strong> by David Flanagan</a>.</p>
<h3 id="the_dom">The DOM</h3>
<p>The Document Object Model is an entirely separate beast to JavaScript, but is implemented natively within it. There are also DOM libraries for other languages that implement the W3 DOM specification when dealing with XML and SGML files.</p>
<p>Understanding the DOM in JavaScript is essential when designing and developing interactions with your HTML and CSS. Thankfully all JavaScript libraries abstract out the pitfalls of DOM scripting so that you don’t have to, but as before, it’s still important for you to understand <em>how</em> so that you can maximise your efficiency in using said library.</p>
<h4 id="useful_resources3">Useful resources:</h4>
<p>Once again the Mozilla Developer Centre provides an excellent <a href="https://developer.mozilla.org/en/DOM">DOM reference section</a>, although it is slightly skewed in favour of the Gecko browser engine. You can also find plenty of <a href="http://www.w3.org/DOM/">information on the DOM at the W3C site</a>.</p>
<h3 id="interaction_with_the_browser">Interaction with the browser</h3>
<p>When writing client-side JavaScript, it is important to take into account how HTML, CSS, and JavaScript interact with the browser directly. At every available opportunity, you should attempt to make sure you are not contradicting the browser, and that you are not rewriting interactions that are already well handled by the browser and operating system.</p>
<p>A good example of this is to make sure you do not break the “back” button. Often this can be achieved by simply using the <code>window.location.replace()</code> method to control which pages appear in the browser history.</p>
<h2 id="libraries">Libraries</h2>
<p>Using libraries in JavaScript has become standard practice. A JavaScript library exists to save time and effort, and to provide a single source of truth (as discussed earlier) for many common tasks within that language.</p>
<p>A JavaScript library provides you a toolbox full of handy devices to make your life easier. It needs to be treated as such, and not as a language in its own right. It is very important to understand the core structures of JavaScript, and how the library of your choice interacts within those structures and your own code.</p>
<p>Every library is different and has its own pros and cons. I’m not going to go into my opinion of those here; perhaps that’s something for another post. They do, however, all interact somewhat differently with JavaScript, and it’s important to understand how the library you choose does that specifically.</p>
<h2 id="summary">Summary</h2>
<p>Hopefully that should get you in the right frame of mind to develop high quality JavaScript code. In the second half of this article I will be looking at specific use of JavaScript in regard to object-orientation.</p>
<p><a href="http://nefariousdesigns.co.uk/archive/2010/10/object-oriented-javascript-follow-up-part-2-technical/">Continue reading part 2 of my object-oriented JavaScript follow-up&hellip;</a></p>
]]></content:encoded>
			<wfw:commentRss>http://nefariousdesigns.co.uk/archive/2010/10/object-oriented-javascript-follow-up-part-1-method/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Premature Publish</title>
		<link>http://nefariousdesigns.co.uk/archive/2010/02/premature-publish/</link>
		<comments>http://nefariousdesigns.co.uk/archive/2010/02/premature-publish/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 09:50:22 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Writing]]></category>

		<guid isPermaLink="false">http://nefariousdesigns.co.uk/?p=463</guid>
		<description><![CDATA[Last night I accidentally published a new post, &#8220;Website builds using Make&#8221; before it was complete. Apologies if you read it and wondered why it never reached a proper conclusion; I&#8217;m still finishing it off. I really really need to move off of WordPress. Needless to say, the completed version of that post should be [...]]]></description>
			<content:encoded><![CDATA[<p>Last night I accidentally published a new post, &#8220;Website builds using Make&#8221; before it was complete. Apologies if you read it and wondered why it never reached a proper conclusion; I&#8217;m still finishing it off.</p>
<p>I really really need to move off of WordPress.</p>
<p>Needless to say, the completed version of that post should be published very soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://nefariousdesigns.co.uk/archive/2010/02/premature-publish/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A CMS Confession</title>
		<link>http://nefariousdesigns.co.uk/archive/2010/01/a-cms-confession/</link>
		<comments>http://nefariousdesigns.co.uk/archive/2010/01/a-cms-confession/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 09:59:45 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Idea]]></category>
		<category><![CDATA[The Future]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://nefariousdesigns.co.uk/?p=255</guid>
		<description><![CDATA[I need to make a confession: I have a bit of a nerdy obsession with Content Management Systems. This probably stems from the fact that I&#8217;ve built several, worked with a number of internal bespoke systems, and have also been involved in implementing an off-the-shelf solution for a number of large sites. As an addition, [...]]]></description>
			<content:encoded><![CDATA[<p>I need to make a confession: I have a bit of a nerdy obsession with Content Management Systems. This probably stems from the fact that I&#8217;ve built several, worked with a number of internal bespoke systems, and have also been involved in implementing an off-the-shelf solution for a number of large sites. As an addition, I&#8217;ve also worked with—and built—several blog publishing systems, which can be viewed as the most basic bespoke CMSs. The upshot of all that is that I&#8217;ve spent so long on CMS related problems, solving them has become a rewarding experience.</p>
<p><span id="more-255"></span></p>
<p>Recently, I&#8217;ve been building a new blog platform, in Django, called “<a href="http://github.com/nefarioustim/nef-blog">nef-blog</a>”. It&#8217;s nothing special; just a quick self-build solution that will get me off of WordPress. However, I&#8217;m still not entirely happy with it, since it will still be building my blog pages at request time (otherwise known as &#8220;frying&#8221; pages). This seems like a needless overhead and, for good performance on popular posts (I do have <em>some</em>), will probably still require some form of caching solution. I&#8217;d much rather have the choice of implementing a mixed fried and baked solution—where &#8220;baked&#8221; pages are generated by some form of printing process, and the output is stored on the file system and served at request time.</p>
<p>Several of my peers have also recently been building baking (or “static CMS”) solutions—most of which are available for perusal on GitHub, despite being in varying stages of completion:</p>
<ul>
<li>“<a href="http://github.com/spjwebster/lanyon/">Lanyon</a>”, by Steve Webster</li>
<li>“<a href="http://github.com/mikewest/fallow/">Fallow</a>”, by Mike West</li>
<li>“<a href="http://github.com/norm/flourish/">Flourish</a>”, by Mark Norman Francis</li>
<li>“<a href="http://github.com/lethain/aym-cms">AYM CMS</a>”, by Will Larson</li>
<li>“<a href="http://github.com/mojombo/jekyll/">Jekyll</a>”, by Tom Preston-Werner</li>
<li>“<a href="http://github.com/lakshmivyas/hyde/">Hyde</a>”, by Lakshmi Vyas</li>
</ul>
<p>This has inspired me to attempt to develop a new CMS; but before I do that, I thought I&#8217;d lay down a sort of treatise of things to take into account when designing and developing a CMS. These are simply my own thoughts on the subject, and I&#8217;d definitely welcome some discussion; I&#8217;d definitely like to be able to update this post in the future with new information garnered from the web developer community.</p>
]]></content:encoded>
			<wfw:commentRss>http://nefariousdesigns.co.uk/archive/2010/01/a-cms-confession/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Babies!</title>
		<link>http://nefariousdesigns.co.uk/archive/2007/06/babies/</link>
		<comments>http://nefariousdesigns.co.uk/archive/2007/06/babies/#comments</comments>
		<pubDate>Wed, 20 Jun 2007 07:27:38 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://nefariousdesigns.co.uk/archive/2007/06/babies/</guid>
		<description><![CDATA[You may have noticed that I&#8217;ve been neglecting my blog over the last 9 months. This is due to Meegan falling pregnant with twins, and their subsequent arrival. Isabella Ada Huegdon (5lb 10oz) and Am&#233;lie Isla Huegdon (5lb 5oz) arrived at 10:02am and 10:27am respectively on the 23rd of May, 2007. I haven&#8217;t had time [...]]]></description>
			<content:encoded><![CDATA[<p>You may have noticed that I&#8217;ve been neglecting my blog over the last 9 months. This is due to Meegan falling pregnant with twins, and their subsequent arrival.</p>
<p>Isabella Ada Huegdon (5lb 10oz) and Am&eacute;lie Isla Huegdon (5lb 5oz) arrived at 10:02am and 10:27am respectively on the 23rd of May, 2007. I haven&#8217;t had time to upload loads of pictures yet, but watch <a href="http://flickr.com/photos/nefarioustim/">my Flickr stream</a>; there are a few there already.</p>
<p>I&#8217;m very happy to be a Dad although it&#8217;s pretty hard going at the moment; in fact, I reckon one baby must be an absolute doddle. To be fair though, Meegan is doing the majority of the work at the moment since I leave for work at 6:30am and get home at 8pm.</p>
<p>Anyway, as far as the blog is concerned, normal service will resume shortly (I&#8217;m writing a couple of posts at the moment).</p>
]]></content:encoded>
			<wfw:commentRss>http://nefariousdesigns.co.uk/archive/2007/06/babies/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Alegria</title>
		<link>http://nefariousdesigns.co.uk/archive/2007/01/alegria/</link>
		<comments>http://nefariousdesigns.co.uk/archive/2007/01/alegria/#comments</comments>
		<pubDate>Sat, 13 Jan 2007 10:40:21 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[Life]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://nefariousdesigns.co.uk/archive/2007/01/alegria/</guid>
		<description><![CDATA[Last night I went to see Cirque du Soleil perform &#8220;Alegria&#8221;, their new show, at the Royal Albert Hall. It was my mother-in-law&#8217;s birthday; but we hadn&#8217;t told her where we were going so, when her and Meeg turned up outside my office late yesterday afternoon, she was none-the-wiser. When I finally made it downstairs [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cirquedusoleil.com"><img src="/blog/images/alegria.jpg" alt="Lloyds TSB Corporate Markets presents Alegria - Cirque du Soleil" class="framed" /></a></p>
<p>Last night I went to see <a href="http://www.cirquedusoleil.com">Cirque du Soleil</a> perform &#8220;Alegria&#8221;, their new show, at the <a href="http://www.royalalberthall.com/">Royal Albert Hall</a>.</p>
<p>It was my mother-in-law&#8217;s birthday; but we hadn&#8217;t told her where we were going so, when her and Meeg turned up outside my office late yesterday afternoon, she was none-the-wiser. When I finally made it downstairs to the street, they were both clearly very excited (although I&#8217;m not sure whether that was due to what might be coming or the fact that they&#8217;d just spent 5 or 10 minutes staring into the window of Angels&#8217; Fancy Dress shop).</p>
<p><span id="more-158"></span></p>
<p>We all decided we were pretty hungry so I took them to <a href="http://www.london-eating.co.uk/2664.htm">Govinda&#8217;s Krishna Restaurant</a> on Soho Street, because the mother-in-law is vegetarian. Govinda&#8217;s is an excellent place to eat whether you&#8217;re veggie or not &#8211; in fact, I&#8217;d actually had lunch there with <a href="http://muffinresearch.co.uk/">Stuart</a> and Tristan earlier in the day. The food is fantastic Indian vegetarian fare and the prices are ridiculously low. In all honesty, I can&#8217;t recommend it enough!</p>
<p>Once we&#8217;d finished our meal, we still had some time to waste so I took them on a leisurely stroll down Shaftesbury Avenue to <a href="http://en.wikipedia.org/wiki/Piccadilly_Circus">Piccadilly Circus</a>. We then continued our meanderings down Piccadilly past <a href="http://www.fortnumandmason.com/">Fortnum &#038; Mason&#8217;s</a> (who happen to have <a href="http://www.thefirstpost.co.uk/index.php?menuID=3&#038;subID=1320">a cool &#8220;Alice in Wonderland&#8221; themed window display</a> at the moment) and <a href="http://www.theritzlondon.com/">The Ritz</a> (considering how expensive their hotel is, you&#8217;d think the website would be better eh?).</p>
<p>It was at this point that I realised we&#8217;d become one of those groups of people I so despise when I&#8217;m in a rush to get to the station after a long day&#8217;s work. You know; the ones who wander aimlessly clogging up the pavement. At this revelation (and also since my pregnant wife was getting a little tired), I hailed a cab and we whisked the mother-in-law off to the Albert Hall.</p>
<p>Once we&#8217;d found our seats in the circle, we settled in for an excellent show &#8211; although sadly, the back parts of the stage were somewhat obscured from our view. However, this didn&#8217;t spoil the show too much and certainly didn&#8217;t hinder our enjoyment.</p>
<p>I&#8217;d never seen Cirque du Soleil before and was quickly dazzled by their fantastic costumes and orchestration. The line-up included some excellent clowns, an aerial high bar, tumblers (who used a really cool cross-shaped trampoline called a &#8220;Power Track&#8221; to enhance their flips and leaps), a hand-balancer, fire-jugglers, a flying-man (a guy on a bungie-cord), russian bars, manipulation, contortion and a synchronised trapeze. Their website has plenty of information about <a href="http://www.cirquedusoleil.com/CirqueDuSoleil/en/showstickets/alegria/acts/">the acts in the show</a>.</p>
<p>We thoroughly enjoyed the show and would recommend anyone else to go see it. I <em>have</em> read reviews that say it&#8217;s nothing new if you&#8217;ve seen Cirque du Soleil before &#8211; so as newcomers, we might just be dazzled by their grace, acrobatics and skill.</p>
<p>All in all, it was an excellent night and the mother-in-law appreciated it greatly.</p>
]]></content:encoded>
			<wfw:commentRss>http://nefariousdesigns.co.uk/archive/2007/01/alegria/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Look at the SIZE of that thing&#8230;</title>
		<link>http://nefariousdesigns.co.uk/archive/2007/01/look-at-the-size-of-that-thing/</link>
		<comments>http://nefariousdesigns.co.uk/archive/2007/01/look-at-the-size-of-that-thing/#comments</comments>
		<pubDate>Sat, 06 Jan 2007 13:14:33 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Science]]></category>
		<category><![CDATA[The Future]]></category>
		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://nefariousdesigns.co.uk/archive/2007/01/look-at-the-size-of-that-thing/</guid>
		<description><![CDATA[Terabyte hard drive anyone? The exponential growth of processor speeds and memory and hard drive sizes sometimes catches me off guard. I mean, I&#8217;m well aware of Moore&#8217;s Law; but since I can still remember the days of programming with only 16k at your disposal, the mind boggles! Jesse James Garrett raises an interesting point [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://news.com.com/2100-1041_3-6147409.html">Terabyte hard drive</a> anyone?</p>
<p>The exponential growth of processor speeds and memory and hard drive sizes sometimes catches me off guard. I mean, I&#8217;m well aware of <a href="http://en.wikipedia.org/wiki/Moore's_law">Moore&#8217;s Law</a>; but since I can still remember the days of programming with only 16k at your disposal, the mind boggles!</p>
<p>Jesse James Garrett raises an interesting point whilst contemplating <a href="http://blog.jjg.net/weblog/2007/01/the_desktop_ter.html">The Desktop Terabyte</a>.</p>
<p>Still, at least <a href="/archive/2007/01/happy-new-year/">server-side back-up scripts</a> won&#8217;t cause so many problems with all that lovely extra space&hellip; Uh&hellip; Right Stu?</p>
]]></content:encoded>
			<wfw:commentRss>http://nefariousdesigns.co.uk/archive/2007/01/look-at-the-size-of-that-thing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Happy New Year!</title>
		<link>http://nefariousdesigns.co.uk/archive/2007/01/happy-new-year/</link>
		<comments>http://nefariousdesigns.co.uk/archive/2007/01/happy-new-year/#comments</comments>
		<pubDate>Tue, 02 Jan 2007 15:42:28 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://nefariousdesigns.co.uk/archive/2007/01/happy-new-year/</guid>
		<description><![CDATA[Happy New Year everybody; I hope you all had a very merry Christmas. My website has been down for a couple of days due to a couple of server issues, but it&#8217;s all back up and running now thanks to some hard work from my server-buddy, Stu. Needless to say, having spent the Christmas period [...]]]></description>
			<content:encoded><![CDATA[<p>Happy New Year everybody; I hope you all had a very merry Christmas.</p>
<p>My website has been down for a couple of days due to a couple of server issues, but it&#8217;s all back up and running now thanks to some hard work from my server-buddy, <a href="http://muffinresearch.co.uk">Stu</a>.</p>
<p>Needless to say, having spent the Christmas period away from my computer and the blogosphere, I have returned revitalised and refreshed. I&#8217;m also pretty good at <a href="http://www.vivapinata.com/">Viva Pinata</a> now as well.</p>
<p> <img src='http://nefariousdesigns.co.uk/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://nefariousdesigns.co.uk/archive/2007/01/happy-new-year/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Big Idea</title>
		<link>http://nefariousdesigns.co.uk/archive/2006/12/the-big-idea/</link>
		<comments>http://nefariousdesigns.co.uk/archive/2006/12/the-big-idea/#comments</comments>
		<pubDate>Tue, 19 Dec 2006 10:12:34 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Idea]]></category>
		<category><![CDATA[Microformats]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://nefariousdesigns.co.uk/archive/2006/12/the-big-idea/</guid>
		<description><![CDATA[It&#8217;s been a while since I blogged &#8211; mainly due to the awesome news that Meegan and I are pregnant, my new job at Yahoo! Europe and the impending Christmas period. For this reason, I thought it was about time I got motivated and started working on something new and exciting. So, during the train [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while since I blogged &#8211; mainly due to the awesome news that Meegan and I are pregnant, my new job at Yahoo! Europe and the impending Christmas period. For this reason, I thought it was about time I got motivated and started working on something new and exciting.</p>
<p>So, during the train ride into work this morning, whilst staring out the window at an awesome morning mist, my thoughts turned to API&#8217;s; more precisely, to writing an application entirely <em>based</em> around an API. I was thinking about how fun it would be to try to write an effective API and then use PHP and JavaScript to manipulate that API to build an application. I also thought it would be an interesting exercise in best-practices; from planning and documentation, through to responsibly using AJAX.</p>
<p><span id="more-150"></span></p>
<h2>Woah! Where did <em>that</em> come from?</h2>
<p>I guess I&#8217;m partly spurred on by <a href="http://adactio.com">Jeremy Keith</a>&#8216;s excellent presentation at <a href="http://2006.dconstruct.org/">d.Construct06</a> entitled &#8220;<a href="http://adactio.com/articles/1181/">The Joy of API</a>&#8220;, as well as Drew McLellan&#8217;s presentation &#8220;Can your website be your API?&#8221; at the last WSG London meet (listen to it via <a href="http://muffinresearch.co.uk/wsg/">the WSG podcast</a>). API&#8217;s are sexy &#8211; all the popular kids have them in one form or another; from REST style <a href="http://www.flickr.com/services/api/">Flickr</a> and <a href="http://del.icio.us/help/api/">de.licio.us</a> through to the Microformat heavy <a href="http://corkd.com/">Corkd</a>. It&#8217;s all happening out there and I want a piece of the action.</p>
<h2>So what&#8217;s the big idea?</h2>
<p>As an amateur cook, I&#8217;ve recently been thinking about purchasing a scrap-book so that I can collect and collate recipes, however, I&#8217;d much rather be able to do this online since I tend to plan meals in my head whilst I&#8217;m at work. There are a huge number of recipe sites out there but they tend to be over complicated, drowning in adverts, ugly and not quite what I want &#8211; so I thought, what the heck, I&#8217;ll write one and try to do a good job! What&#8217;s more, I&#8217;ll try and work to a Web2.0 ethic and promote a community environment.</p>
<p>I&#8217;m well aware that I might crash and burn half way through the process &#8211; but since I&#8217;m approaching this as a learning experience, I&#8217;m going to get <em>something</em> out of it even if it <em>is</em> a few harsh lessons.</p>
<h2>What do you hope to learn?</h2>
<p>Quite a lot really. I&#8217;m interested in improving my understanding of user interface design, of web application design, of information architecture for the web, and, at a technology level, of Microformats and the YUI. I&#8217;m also looking to discover new things about the languages I&#8217;ll be using; from the potential minefield that is PHP through to the responsible use of JavaScript, as mentioned earlier.</p>
<h2>So what next?</h2>
<p>Over the next couple of days I&#8217;ll start to look at planning the project and I&#8217;ll try to blog the process. I&#8217;ll also include all my documentation and will hopefully get some feedback (including ideas &#8211; let&#8217;s open up the floor here).</p>
<p>Hopefully, by the end of this, I&#8217;ll have learnt some stuff <em>and</em> created a handy application.</p>
]]></content:encoded>
			<wfw:commentRss>http://nefariousdesigns.co.uk/archive/2006/12/the-big-idea/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

