<?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>George Paterson</title>
	<atom:link href="http://www.georgepaterson.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.georgepaterson.com</link>
	<description>People are less likely to shoot at you if you smile at them. - Jack Churchill</description>
	<lastBuildDate>Mon, 12 Dec 2011 10:08:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>jQuery UI custom select widget</title>
		<link>http://www.georgepaterson.com/2011/11/26/jquery-ui-custom-select-widget/</link>
		<comments>http://www.georgepaterson.com/2011/11/26/jquery-ui-custom-select-widget/#comments</comments>
		<pubDate>Sat, 26 Nov 2011 22:17:41 +0000</pubDate>
		<dc:creator>George Paterson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[jQuery UI]]></category>

		<guid isPermaLink="false">http://www.georgepaterson.com/?p=659</guid>
		<description><![CDATA[This is the first build of the jQuery UI custom select widget available on GitHub. There is a demo page and wiki page available outlining how the widget works. It is hoped that the widget will simplify custom select development. The jQuery UI custom select widget is designed as a method for applying a custom [...]]]></description>
			<content:encoded><![CDATA[<p>This is the first build of the <a href="http://github.com/georgepaterson/jquery-ui">jQuery UI custom select widget</a> available on GitHub. There is a <a href="http://www.georgepaterson.com/sandbox/jquery-ui-custom-select-demo/">demo page</a> and <a href="https://github.com/georgepaterson/jquery-ui/wiki/Selectgroup">wiki page</a> available outlining how the widget works. It is hoped that the widget will simplify custom select development.</p>
<p>The jQuery UI custom select widget is designed as a method for applying a custom design to a native HTML select element. Currently the only applicable method for doing this to replace the select element entirely, duplicate it&#8217;s functionality in a new element and replicate any changes to the new element back to the select element.</p>
<p><span id="more-659"></span></p>
<p>Scott while at Filament group developed such a method in 2009 creating a <a href="http://filamentgroup.com/lab/jquery_ui_selectmenu_an_aria_accessible_plugin_for_styling_a_html_select/">selectmenu</a>, this has received on going support from <a href="http://github.com/fnagel/jquery-ui">Felix Nagel</a>.</p>
<p>During 2011 a project was developed at <a href="http://www.lbi.co.uk/">LBi London</a> that required a large number of custom selects. Applying the current custom select had significant performance issues as every select had their options implemented at DOM ready. We sort an alternative pattern for generating custom selects and looked to the <a href="http://en.wikipedia.org/wiki/Flyweight_pattern">flyweight pattern</a>. <a href="http://github.com/rayui">Ray Brooks</a> implemented this pattern as a <a href="http://github.com/rayui/flyweight-jquery-custom-select">jQuery plugin</a>.</p>
<p>The custom select widget is an implementation of the flyweight pattern referencing both Ray&#8217;s flyweight custom select and the current selectmenu widget.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.georgepaterson.com/2011/11/26/jquery-ui-custom-select-widget/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fatherhood</title>
		<link>http://www.georgepaterson.com/2011/11/14/fatherhood/</link>
		<comments>http://www.georgepaterson.com/2011/11/14/fatherhood/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 14:04:11 +0000</pubDate>
		<dc:creator>George Paterson</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://www.georgepaterson.com/?p=617</guid>
		<description><![CDATA[It&#8217;s been a bit quiet around here recently but there&#8217;s a very good reason for that. On Sunday 30th October 2011 at 07:34 am i became the father to a baby boy. His name is Thomas Paterson and both mother and baby are doing great, although sleep patterns currently follow an ambiguous schedule only Thomas [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a bit quiet around here recently but there&#8217;s a very good reason for that.</p>
<p>On Sunday 30th October 2011 at 07:34 am i became the father to a baby boy. His name is Thomas Paterson and both mother and baby are doing great, although sleep patterns currently follow an ambiguous schedule only Thomas seems to be aware of.</p>
<p>It is only after my paternity leave that i find time to write this but now that life resumes it&#8217;s gentle ebb and flow i too return to development.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.georgepaterson.com/2011/11/14/fatherhood/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript Performance: jQuery.each and .each versus alternatives</title>
		<link>http://www.georgepaterson.com/2011/08/30/javascript-performance-jquery-each-and-each-versus-alternatives/</link>
		<comments>http://www.georgepaterson.com/2011/08/30/javascript-performance-jquery-each-and-each-versus-alternatives/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 21:44:20 +0000</pubDate>
		<dc:creator>George Paterson</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://www.georgepaterson.com/?p=573</guid>
		<description><![CDATA[Iterating across an array is a significant feature of JavaScript development. There are multiple methods available to achieve this, the native for and while loops and if you are using the jQuery JavaScript library there is jQuery.each and .each. jQuery.each is designed to iterate over arrays and array like objects. .each is designed to iterate [...]]]></description>
			<content:encoded><![CDATA[<p>Iterating across an array is a significant feature of JavaScript development. There are multiple methods available to achieve this, the native for and while loops and if you are using the jQuery JavaScript library there is jQuery.each and .each.</p>
<p><a href="http://api.jquery.com/jQuery.each/">jQuery.each</a> is designed to iterate over arrays and array like objects. <a href="http://api.jquery.com/each/">.each</a> is designed to iterate over jQuery objects and execute a function for each.</p>
<p><span id="more-573"></span></p>
<p>It seems to be a commonly held belief that a for or while loop should be used instead of the two jQuery alternatives. This belief is based on performance, as jQuery has to invoke additional code to complete the same task.</p>
<p>I tried a number of sources but the best way to find the truth is through experimentation. To create an experiment i use <a href="http://jsperf.com/">jsper.com</a> as it allows you to run performance tests on snippets of your code, it is particularly useful as the same test can be run from many different browsers.</p>
<p>Having a quick look at <a href="http://jsperf.com/">jsper.com</a> i found some existing tests, one of interest was <a href="http://jsperf.com/jquery-each-vs-for-loop/24">Addy Osmani&#8217;s revision</a> which had comparative results for for, while and jQuery.each loops. The .each test though seemed to be off by an order of magnitude. What&#8217;s missing here is that .each will look for the array of objects in the DOM, performing the same task as var a = $(&#8216;*&#8217;).get() which is declared outside of the iteration for all the other test.</p>
<p>This represents an unfair advantage for the other methods, so i created a <a href="http://jsperf.com/jquery-each-vs-for-loop/38">new revision</a> of the test where the DOM operation was done as part of the test. From this <a href="http://jsperf.com/jquery-each-vs-for-loop/38">.each is still slower than native methods</a> but only by a small margin.</p>
<p>Using these results it would seem that the advantage of performance is insufficient to force usage of the for or while loop over the jQuery equivalents. Although there may be a saving in performance the jQuery abstraction allows for shorter, more succinct code, using a standard format  that is easier to understand.</p>
<p>Common abstractions are useful in software development, if using jQuery i would recommend using jQuery.each and .each rather than a native approach; which should be kept in reserve for applications that require maximum performance.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.georgepaterson.com/2011/08/30/javascript-performance-jquery-each-and-each-versus-alternatives/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>jQuery HTML5 video background 1.1.1</title>
		<link>http://www.georgepaterson.com/2011/08/30/jquery-html5-video-background-1-1-1/</link>
		<comments>http://www.georgepaterson.com/2011/08/30/jquery-html5-video-background-1-1-1/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 11:39:36 +0000</pubDate>
		<dc:creator>George Paterson</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.georgepaterson.com/?p=562</guid>
		<description><![CDATA[Release 1.1.1 is now available on GitHub. This release includes a number of performance enhancements and fixes but retains the existing settings from the first release. Additionally i&#8217;ve created a number of public methods for the plugin, this will allow access to some of the internal features of the plugin. Public methods play: Trigger a [...]]]></description>
			<content:encoded><![CDATA[<style>
dt {
  float: left;
  width: 160px;
}
dd {
  margin: 0 0 10px 160px;
}
</style>
<p><a href="https://github.com/georgepaterson/jquery-videobackground/tree/1.1.1">Release 1.1.1</a> is now available on <a href="https://github.com/georgepaterson/jquery-videobackground">GitHub</a>. This release includes a number of performance enhancements and fixes but retains the existing settings from the first release. Additionally i&#8217;ve created a number of public methods for the plugin, this will allow access to some of the internal features of the plugin.</p>
<p><span id="more-562"></span></p>
<h2>Public methods</h2>
<dl>
<dt>play:</dt>
<dd>Trigger a play/pause event on the chosen video background. Will play if the video is already paused. Will pause if the video is already playing.</dd>
<dt>mute:</dt>
<dd>Trigger a mute/unmute event on the chosen video background. Will unmute if the video is already muted. Will mute if the video is unmuted.</dd>
<dt>destroy:</dt>
<dd>Will destroy the chosen video background. Unbinds events bound when the video background is initialised and removes HTML attached to the DOM by the plugin. If a controlPosition parameter is set this will also have to be set to safely remove all HTML elements from the DOM.</dd>
<dt>resize:</dt>
<dd>When invoked this will resize the video background to the height of the document or window. The video background height affects the height of the document which affects the video background&#8217;s ability to negatively resize.</dd>
</dl>
<p>The <a href="http://www.georgepaterson.com/sandbox/jquery-html5-video-background-demo/">demo page</a> has been updated with the new code which when minified is 8Kb. You can find a shell file to minify the code in the build folder.</p>
<p>The source and issue tracking is available on <a href="http://github.com/georgepaterson/jquery-videobackground">GitHub</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.georgepaterson.com/2011/08/30/jquery-html5-video-background-1-1-1/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>Object Oriented JavaScript: Modular development</title>
		<link>http://www.georgepaterson.com/2011/07/17/object-oriented-javascript-modular-development/</link>
		<comments>http://www.georgepaterson.com/2011/07/17/object-oriented-javascript-modular-development/#comments</comments>
		<pubDate>Sun, 17 Jul 2011 19:15:42 +0000</pubDate>
		<dc:creator>George Paterson</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.georgepaterson.com/?p=536</guid>
		<description><![CDATA[In my previous article i talked about the fundamental concepts of object oriented programming, abstraction, encapsulation, inheritance and polymorphism. These concepts are a part of developing object oriented code and if structured appropriately can be used to create highly modular reusable code. Developing reusable code is a necessity of software development, it allows for a [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous article i talked about the <a href="http://www.georgepaterson.com/2011/06/12/object-oriented-javascript-fundamental-concepts/">fundamental concepts</a> of object oriented programming, abstraction, encapsulation, inheritance and polymorphism. These concepts are a part of developing object oriented code and if structured appropriately can be used to create highly modular reusable code.</p>
<p>Developing reusable code is a necessity of software development, it allows for a more efficient development cycle and continuous improvement of an existing development.</p>
<p>The alternative to code reuse is code salvage. Code salvage is an inefficient method of stripping the code down for it&#8217;s useful parts and discarding the rest. In creating modular code we hope to support code reuse by making all of the code module useful.</p>
<p><span id="more-536"></span></p>
<p>To create modular code we need to look at the key characteristics of a module. For that i am going to reference Bertrand Meyer&#8217;s <sup>[<a href="#cite-one">1</a>]</sup> <sup>[<a href="#cite-two">2</a>]</sup> five criteria for modular development from his book Object-Oriented Software Construction.<sup>[<a href="#cite-three">3</a>]</sup> <sup>[<a href="#cite-four">4</a>]</sup></p>
<ul>
<li><em>Modular Decomposability.</em> A software construction method satisfies Modular Decomposability if it helps in the task of decomposing a software problem into a small number of less complex subproblems, connected by a simple structure, and independent enough to allow further work to proceed separately on each item.</li>
<li><em>Modular Composability.</em> A method satisfies Modular Composability if it favours the products of software elements which may then be freely combined with each other to produce new systems, possibly in an environment quite different from the one in which they were initially developed.</li>
<li><em>Modular Understandability.</em> A method favours Modular Understandability if it helps produce software which a human reader can understand each module without having to know the others, or, at worst, by having to examine only a few of the others.</li>
<li><em>Modular Continuity.</em> A method satisfies Modular Continuity if, in the software architectures that it yields, a small change in the problem specification will trigger a change of just one module, or a small number of modules.</li>
<li><em>Modular Protection.</em> A method satisfied Modular Protection if it yields architectures in which the effect of an abnormal condition occurring at run time in a module will remain confined to that module, or at worst will only propagate to a few neighbouring modules.</li>
</ul>
<p>The scale of modularity for each of the criteria may vary per module but by using these criteria to guide development of modules we should be able to create discrete, understandable and robust modules that can be used as building blocks for projects.</p>
<p>We can assess the affect of leveraging these principles by understanding two artefacts of code development, coupling and cohesion.</p>
<ul>
<li><em>Coupling.</em> The reliance of the module on other modules and the module&#8217;s environment.</li>
<li><em>Cohesion.</em> A cohesive module makes sense as a discrete entity, it has a clearly defined role, purpose and it&#8217;s internal function is easy to understand.</li>
</ul>
<p>Modular code should have low coupling and high cohesion. The lower the coupling, the less reliance the module has on external factors to function, this increases the chance that the module can be reused. Higher cohesion also increases the likelihood that a module can be reused, as it&#8217;s boundary is better defined making it easier to extract.</p>
<h2>Summary</h2>
<p>By using object oriented programming to create modular code we are trying to create code that we can reuse across projects. JavaScript libraries and the plugins they support are great examples of modular reusable code and in using these libraries we can focus on increasingly complex problems rather than reiterate the fundamentals like cross browser classname selection.</p>
<p><em>Nanos gigantium humeris insidentes <sup>[<a href="#cite-five">5</a>]</sup></em> &#8211; By creating, sharing and using modular code we may all stand on the shoulders of giants.</p>
</p>
<h2>References</h2>
<ol>
<li id="cite-one"><a href="http://se.ethz.ch/~meyer/">http://se.ethz.ch/~meyer/</a>. Retrieved 17/07/2011.</li>
<li id="cite-two"><a href="http://en.wikipedia.org/wiki/Bertrand_Meyer">http://en.wikipedia.org/wiki/Bertrand_Meyer</a>. Retrieved 17/07/2011.</li>
<li id="cite-three"><a href="http://www.amazon.co.uk/Object-Oriented-Software-Construction-Prentice-Hall-Resource/dp/0136291554/">http://www.amazon.co.uk/Object-Oriented-Software-Construction-Prentice-Hall-Resource/dp/0136291554/</a>. Retrieved 17/07/2011.</li>
<li id="cite-four"><a href="http://en.wikipedia.org/wiki/Object-Oriented_Software_Construction">http://en.wikipedia.org/wiki/Object-Oriented_Software_Construction</a>. Retrieved 17/07/2011.</li>
<li id="cite-five"><a href="http://en.wikipedia.org/wiki/Standing_on_the_shoulders_of_giants">http://en.wikipedia.org/wiki/Standing_on_the_shoulders_of_giants</a>. Retrieved 17/07/2011.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.georgepaterson.com/2011/07/17/object-oriented-javascript-modular-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>America&#8217;s Cup site released</title>
		<link>http://www.georgepaterson.com/2011/07/03/americas-cup-site-released/</link>
		<comments>http://www.georgepaterson.com/2011/07/03/americas-cup-site-released/#comments</comments>
		<pubDate>Sun, 03 Jul 2011 18:07:56 +0000</pubDate>
		<dc:creator>George Paterson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.georgepaterson.com/?p=492</guid>
		<description><![CDATA[This week we at LBi London released the first phase of the new America&#8217;s Cup website. I had the opportunity to work with the hosts of the oldest active trophy in international sport as lead interface developer, with a team including Francesca Mancuso, Aaron Faber, Jamie Collins and Pia Gamon. The site itself was built [...]]]></description>
			<content:encoded><![CDATA[<p>This week we at <a href="http://www.lbi.co.uk/">LBi London</a> released the first phase of the new <a href="http://www.americascup.com">America&#8217;s Cup website</a>. I had the opportunity to work with the hosts of the <a href="http://en.wikipedia.org/wiki/America%27s_Cup">oldest active trophy in international sport</a> as lead interface developer, with a team including <a href="http://twitter.com/just_francesca">Francesca Mancuso</a>, <a href="http://twitter.com/afaber">Aaron Faber</a>, <a href="http://twitter.com/Collins1892">Jamie Collins</a> and <a href="http://twitter.com/coolwoc">Pia Gamon</a>.</p>
<p>The site itself was built on <a href="http://www.episerver.com/">EpiServer</a>; which means .Net development and some of .Net&#8217;s more interesting aspects (web forms etc). What we produced is a HTML5 based site that is progressively enhanced using CSS and JavaScript. We couldn&#8217;t use all the elements HTML5 supports because we couldn&#8217;t be reliant on JavaScript for presentation in IE7 and 8. JavaScript development utilised <a href="http://jquery.com/">jQuery</a> and<a href="http://jqueryui.com/"> jQuery UI</a> libraries.</p>
<p>This is only the first phase of ongoing development, with performance improvements including minification and new features for the site but an important first step in supporting one of the great yachting competitions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.georgepaterson.com/2011/07/03/americas-cup-site-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery HTML5 video background 1.0.0</title>
		<link>http://www.georgepaterson.com/2011/06/13/jquery-html5-video-background-1-0-0/</link>
		<comments>http://www.georgepaterson.com/2011/06/13/jquery-html5-video-background-1-0-0/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 00:07:35 +0000</pubDate>
		<dc:creator>George Paterson</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.georgepaterson.com/?p=474</guid>
		<description><![CDATA[I&#8217;ve recently been working on a jQuery plugin that uses a HTML5 video as the background for a page. An idea that perhaps owes far too much of it&#8217;s inception to splash pages, it was worth investigating; as a test for HTML5 video player development and because of it&#8217;s interesting use of the video element. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently been working on a jQuery plugin that uses a HTML5 video as the background for a page. An idea that perhaps owes far too much of it&#8217;s inception to splash pages, it was worth investigating; as a test for HTML5 video player development and because of it&#8217;s interesting use of the video element.</p>
<p><span id="more-474"></span></p>
<p>There is a <a href="http://www.georgepaterson.com/sandbox/jquery-html5-video-background-demo/">demo page</a> available. I&#8217;ve used the existing site theme for the <a href="http://www.georgepaterson.com/sandbox/jquery-html5-video-background-demo/">demo page</a> which should adequately show the plugin is capable of being applied anywhere but lacks the impact a dedicated page design would provide.</p>
<p>The plugin should work in any browser that supports HTML5 video and although I&#8217;ve provided some styling in the <a href="http://www.georgepaterson.com/sandbox/jquery-html5-video-background-demo/">demo page</a> and in the <a href="http://github.com/georgepaterson/jquery-videobackground">source on GitHub</a>, your actual page is likely to be bespoke so the CSS is only provided as an example.</p>
<p>The source and issue tracking is available on <a href="http://github.com/georgepaterson/jquery-videobackground">GitHub</a>.</p>
<h2>Update &#8211; 30th August 2011</h2>
<p><a href="https://github.com/georgepaterson/jquery-videobackground/tree/1.1.1">A new version of the plugin</a> has been created including fixes and ideas from the comments here and <a href="https://github.com/georgepaterson/jquery-videobackground/issues">issues on GitHub</a>. Find out more at the blog post <a href="http://www.georgepaterson.com/2011/08/30/jquery-html5-video-background-1-1-1/">jQuery HTML5 video background 1.1.1</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.georgepaterson.com/2011/06/13/jquery-html5-video-background-1-0-0/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>Object oriented JavaScript: Fundamental concepts</title>
		<link>http://www.georgepaterson.com/2011/06/12/object-oriented-javascript-fundamental-concepts/</link>
		<comments>http://www.georgepaterson.com/2011/06/12/object-oriented-javascript-fundamental-concepts/#comments</comments>
		<pubDate>Sun, 12 Jun 2011 18:44:45 +0000</pubDate>
		<dc:creator>George Paterson</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.georgepaterson.com/?p=462</guid>
		<description><![CDATA[JavaScript is a dynamic, highly expressive[1] multi-paradigm language[2]. JavaScript has had it&#8217;s problems, from a weak specification and poor initial implementation it has matured as the Web has and become a ubiquitous Web technology. Commonly used for Web client interactions it has also proven itself capable of powering Web servers and other devices.[3]. As JavaScript [...]]]></description>
			<content:encoded><![CDATA[<p>JavaScript is a dynamic, highly expressive<sup>[<a href="#cite-one">1</a>]</sup> multi-paradigm language<sup>[<a href="#cite-two">2</a>]</sup>. JavaScript has had it&#8217;s problems, from a weak specification and poor initial implementation it has matured as the Web has and become a ubiquitous Web technology. Commonly used for Web client interactions it has also proven itself capable of powering Web servers and other devices.<sup>[<a href="#cite-three">3</a>]</sup>.</p>
<p>As JavaScript development has matured Object Oriented programming has become the main programming paradigm, it is a paradigm shared with Java, C++ and many other languages. JavaScript is an object based language, lacking some of the traditional features of an Object Oriented language, it is a highly expressive language with alternative methods for classes, information hiding and inheritance<sup>[<a href="#cite-one">1</a>]</sup>.</p>
<p><span id="more-462"></span></p>
<p>Developing Object Oriented JavaScript has a number of benefits for code quality and reuse. This article will focus on Object Oriented Programming&#8217;s four fundamental concepts, abstraction, encapsulation, inheritance and polymorphism<sup>[<a href="#cite-seven">7</a>]</sup>.</p>
<h2>Abstraction</h2>
<p>Only the possible states and behaviours of the abstracted object are accessible, the internal implementation of the object remains hidden. By abstracting the internal implementation of the object, we make the object&#8217;s purpose easier to understand<sup>[<a href="#cite-four">4</a>]</sup>.</p>
<pre>
function Video(element, options) {
	this.Volume = function(number) {
		var loudness = element.volume;
		loudness = loudness + number;
		...
			element.volume = loudness;
		...
	}
}
</pre>
<p>When the Volume method is invoked there are a number of possible states for the volume. We don&#8217;t need to know what these states are, only that by invoking the Volume method we are attempting to change the volume by a given value.</p>
<h2>Encapsulation</h2>
<p>The object is structured to be self-contained, everything the object needs is available internally. The internal state of the object is not directly accessible externally except through the abstraction layer<sup>[<a href="#cite-five">5</a>]</sup>.</p>
<pre>
function Video(element, options) {
	this.Volume = function(number) {
		var loudness = element.volume;
		loudness = loudness + number;
		...
			element.volume = loudness;
		...
	}
}
</pre>
<p>When Volume is given a value, what we need to alter the volume of the video element is available internally. We cannot alter loudness except through the Volume abstraction.</p>
<h2>Inheritance</h2>
<p>Through inheritance, one object can inherit the characteristics of another object, this allows an existing object to be extended and similar objects to share properties and behaviours<sup>[<a href="#cite-six">6</a>]</sup>.</p>
<pre>
function Video(element, options) {
	this.Play = function() {
		...
	}
}
function Audio(element, options) {
	...
}
Audio.prototype = new Video();
var audio = new Audio();
audio.Play();
</pre>
<p>Using prototype, Audio inherits the properties of Video allowing the audio instance to use Video&#8217;s Play method.</p>
<h2>Polymorphism</h2>
<p>Different objects can respond to the same name in different ways, with the response specific to the object<sup>[<a href="#cite-seven">7</a>]</sup>.</p>
<pre>
function Video(element, options) {
	this.Play = function() {
		...
	}
}
function Audio(element, options) {
	this.Play = function() {
		...
	}
}
Audio.prototype = new Video();
var audio = new Audio();
audio.Play();
</pre>
<p>Audio inherits a Play method from Video but we may want to alter the Play functionality for Audio. We can overload the Play method with a new Audio Play method.</p>
<h2>Summary</h2>
<p>Abstraction, encapsulation, inheritance and polymorphism are the building blocks of Object Oriented Programming. Abstraction and encapsulation share a similar conceptual space while inheritance and polymorphism are also linked, by understanding how these concepts work we can better structure our solutions to large programming problems.</p>
<p>Understanding these terms alone though does not necessarily lead to better code quality or reuse. In the next article i&#8217;ll look at Bertrand Meyer&#8217;s five criteria for modularity from his book Object Oriented Software Construction and how these criteria can guide development practice in creating modular, reusable code.</p>
<h2>References</h2>
<ol>
<li id="cite-one"><a href="http://javascript.crockford.com/javascript.html">http://javascript.crockford.com/javascript.html</a>. Retrieved 29/05/2011.</li>
<li id="cite-two"><a href="http://en.wikipedia.org/wiki/List_of_multi-paradigm_programming_languages">http://en.wikipedia.org/wiki/List_of_multi-paradigm_programming_languages</a>. Retrieved 29/05/2011.</li>
<li id="cite-three"><a href="http://javascript.crockford.com/popular.html">http://javascript.crockford.com/popular.html</a>. Retrieved 29/05/2011.</li>
<li id="cite-four"><a href="http://en.wikipedia.org/wiki/Abstraction_(computer_science)">http://en.wikipedia.org/wiki/Abstraction_(computer_science)</a>. Retrieved 31/05/2011.</li>
<li id="cite-five"><a href="http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming)">http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming)</a>. Retrieved 31/05/2011.</li>
<li id="cite-six"><a href="http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming)">http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming)</a>. Retrieved 31/05/2011.</li>
<li id="cite-seven"><a href="http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming)">http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming)</a>. Retrieved 31/05/2011.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.georgepaterson.com/2011/06/12/object-oriented-javascript-fundamental-concepts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CSS sticky footer</title>
		<link>http://www.georgepaterson.com/2011/04/18/css-sticky-footer/</link>
		<comments>http://www.georgepaterson.com/2011/04/18/css-sticky-footer/#comments</comments>
		<pubDate>Mon, 18 Apr 2011 12:20:40 +0000</pubDate>
		<dc:creator>George Paterson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.georgepaterson.com/?p=329</guid>
		<description><![CDATA[A number of web site designs require the page footer to stick to the bottom of a page, no matter the content. There are other solutions but after using a min-height solution for a number of years i have found it to be the most robust. The increasing maturity of the browser market means the [...]]]></description>
			<content:encoded><![CDATA[<p>A number of web site designs require the page footer to stick to the bottom of a page, no matter the content. There are other solutions but after using a min-height solution for a number of years i have found it to be the most robust.</p>
<p>The increasing maturity of the browser market means the CSS has simplified to using min-height only. There are alternative solutions for min-height support using JavaScript, alternatively should the CSS fail it should not cause a significant issue to site usability.</p>
<p><span id="more-329"></span></p>
<h2>The Objective:</h2>
<p>Position the footer element so that it is at the bottom or below the viewport irrespective of the content.</p>
<h2>The Solution:</h2>
<p>The footer element will be positioned in the padded area of the previous sibling element using negative margin.</p>
<p>To achieve this the parent elements (html, body, #page) must be set to 100% height. The previous sibling element (#page-group) must be set to a min-height of 100% and then given a padding equal to the size of the footer element (#footer) plus any additional padding needed for the design.</p>
<p>This will push the vertical space of those elements beyond the viewport to the amount of padding applied. Use a negative margin to bring the footer element back within the viewport, unless the total content is greater than the viewport to start with.</p>
<h2>The CSS:</h2>
<pre>
html,
body,
#page {
  height: 100%;
}
#page-group {
  min-height: 100%;
}
#content {
  padding: 0 0 50px;
}
#footer {
  margin: -50px 0 0;
}
</pre>
<pre>
<h2>The HTML:</h2>

&lt;!DOCTYPE html>
&lt;html lang="en-GB" dir="ltr">
  &lt;head>

  &lt;/head>
  &lt;body>
    &lt;div id="page">
      &lt;div id="page-group">
        &lt;header id="header" role="banner">

        &lt;/header>
        &lt;div id="content">
          &lt;div id="main" role="main">

          &lt;/div>
          &lt;aside id="aside" role="complementary">

          &lt;/aside>
        &lt;/div>
      &lt;/div>
      &lt;footer id="footer" role="contentinfo">

      &lt;/footer>
    &lt;/div>
  &lt;/body>
&lt;/html>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.georgepaterson.com/2011/04/18/css-sticky-footer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Cargo cult CSS resets</title>
		<link>http://www.georgepaterson.com/2011/03/22/cargo-cult-css-resets/</link>
		<comments>http://www.georgepaterson.com/2011/03/22/cargo-cult-css-resets/#comments</comments>
		<pubDate>Tue, 22 Mar 2011 21:56:16 +0000</pubDate>
		<dc:creator>George Paterson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Cargo Cult]]></category>

		<guid isPermaLink="false">http://www.georgepaterson.com/?p=315</guid>
		<description><![CDATA[In my previous article cargo cult science and web development, i talked about Richard Feynman&#8217;s excellent announcement address on cargo cult science, referencing the cargo cults and how web development can suffer from cargo cult development. I didn&#8217;t give a specific example at the time because the one i offer now is rather contentious and [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous article <a href="http://www.georgepaterson.com/2011/03/22/cargo-cult-science-and-web-development/">cargo cult science and web development</a>, i talked about Richard Feynman&#8217;s excellent <a href="http://www.georgepaterson.com/wp-content/uploads/2011/03/cargo-cult-science.txt">announcement address on cargo cult science</a>, referencing the cargo cults and how web development can suffer from cargo cult development.</p>
<p>I didn&#8217;t give a specific example at the time because the one i offer now is rather contentious and i didn&#8217;t want it to draw away from the understanding of cargo cult development.</p>
<p>CSS resets, as investigated by <a href="http://meyerweb.com/eric/thoughts/2008/01/15/resetting-again/">Eric Meyer</a> and others, is a style sheet used by a developer to set a cross browser baseline style. It removes any styling that may be applied by the browser rendering the elements in to a controlled initial state. The principle is that the developer is now in full control of styling for all elements on the site.</p>
<p><span id="more-315"></span></p>
<p>The principle is good, the developer should be in complete control of their styles. The application is flawed, while a developer may attempt to develop for all possible circumstances, the developer is not omniscient. New content and therefore new element combinations will be developed as the site matures, these element combinations will be unplanned by the developer.</p>
<p>By forcing all elements to effectively be unstyled, in a situation unplanned by the developer, the new element combinations will be raised as a developer failure because the reset style sheet declares the developer as omniscient when quite obviously they are not.</p>
<p>By taking CSS reset style sheets verbatim and applying them to our sites without fully considering what the reset is doing and it&#8217;s effect, we have engaged in <a href="http://www.georgepaterson.com/2011/03/22/cargo-cult-science-and-web-development/">cargo cult development</a>.</p>
<p>Instead we should try to understand the principles reset style sheets espouse and integrate that into our own development methods. That way we can still pretend to be omniscient to our clients.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.georgepaterson.com/2011/03/22/cargo-cult-css-resets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

