<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:blogChannel="http://backend.userland.com/blogChannelModule" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" version="2.0">
  <channel>
    <title>HACKINGON.NET</title>
    <description>Pragmatic ALT.NET Web Development</description>
    <link>http://hackingon.net/</link>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <generator>BlogEngine.NET 1.4.5.0</generator>
    <language>en-AU</language>
    <blogChannel:blogRoll>http://hackingon.net/opml.axd</blogChannel:blogRoll>
    <blogChannel:blink>http://www.dotnetblogengine.net/syndication.axd</blogChannel:blink>
    <dc:creator>Liam McLennan</dc:creator>
    <dc:title>HACKINGON.NET</dc:title>
    <geo:lat>-27.488160</geo:lat>
    <geo:long>153.208900</geo:long>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Hackingonnet" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="hackingonnet" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
      <title>My New BDD Style</title>
      <description>&lt;p&gt;I have made a change to my code-based BDD style. I start with a scenario such as:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Pre-Editing&lt;/p&gt;
&lt;p&gt;* Given I am a book editor     &lt;br /&gt;
* And some chapters are locked and some are not      &lt;br /&gt;
* When I view the list of chapters for editing      &lt;br /&gt;
* Then I should see some chapters are editable and are not locked      &lt;br /&gt;
* And I should see some chapters are not editable and are locked&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;and I implement it using a modified SpecUnit base class as:&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:5f63cf6b-c20e-4b0c-bb9e-c3286cfb4899" style="padding: 0px; margin: 0px; display: inline; float: none;"&gt;
&lt;pre class="brush: csharp; gutter: false; first-line: 1; tab-size: 2;  toolbar: true; "&gt;
[Concern(&amp;quot;Chapter Editing&amp;quot;)]
    public class when_pre_editing_a_chapter : BaseSpec
    {
        private User i;
        // other context variables

        protected override void Given()
        {
            i_am_a_book_editor();
            some_chapters_are_locked_and_some_are_not();
        }

        protected override void Do()
        {
            i_view_the_list_of_chapters_for_editing();
        }

        private void i_am_a_book_editor()
        {
            i = new UserBuilder().WithUsername(&amp;quot;me&amp;quot;).WithRole(UserRole.BookEditor).Build();
        }

        private void some_chapters_are_locked_and_some_are_not()
        {
        }

        private void i_view_the_list_of_chapters_for_editing()
        {
        }

        [Observation]
        public void should_see_some_chapters_are_editable_and_are_not_locked()
        {
        }

        [Observation]
        public void should_see_some_chapters_are_not_editable_and_are_locked()
        {
        }
    }&lt;/pre&gt;
&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;p&gt;and the output from the specunit report tool is:&lt;/p&gt;
&lt;h4&gt;Chapter Editing specifications&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 context, 2 specifications&lt;/h4&gt;
&lt;h5&gt;Chapter Editing, when pre editing a chapter&amp;nbsp;&amp;nbsp;&amp;nbsp; 2 specifications&lt;/h5&gt;
&lt;ul&gt;
    &lt;li&gt;should see some chapters are editable and are not locked&lt;/li&gt;
    &lt;li&gt;should see some chapters are not editable and are locked&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The intent is to provide a clear mapping from story &amp;ndash;&amp;gt; scenarios &amp;ndash;&amp;gt; bdd tests.&lt;/p&gt;</description>
      <link>http://hackingon.net/post/My-New-BDD-Style.aspx</link>
      <author>liam.mclennan.nospam@nospam.gmail.com (liammclennan)</author>
      <comments>http://hackingon.net/post/My-New-BDD-Style.aspx#comment</comments>
      <guid>http://hackingon.net/post.aspx?id=36b76105-669e-411e-81ae-92330d360758</guid>
      <pubDate>Wed, 17 Mar 2010 11:02:00 +1000</pubDate>
      <dc:publisher>liammclennan</dc:publisher>
      <pingback:server>http://hackingon.net/pingback.axd</pingback:server>
      <pingback:target>http://hackingon.net/post.aspx?id=36b76105-669e-411e-81ae-92330d360758</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://hackingon.net/trackback.axd?id=36b76105-669e-411e-81ae-92330d360758</trackback:ping>
      <wfw:comment>http://hackingon.net/post/My-New-BDD-Style.aspx#comment</wfw:comment>
      <wfw:commentRss>http://hackingon.net/syndication.axd?post=36b76105-669e-411e-81ae-92330d360758</wfw:commentRss>
    </item>
    <item>
      <title>Changing Platform</title>
      <description>&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="seven_samurai" border="0" alt="seven_samurai" align="right" src="http://hackingon.net/image.axd?picture=WindowsLiveWriter/ChangingPlatform/4890EED4/seven_samurai.jpg" width="174" height="244" /&gt; From time to time a developer makes a break from their platform of choice (.NET, Java, VB, Access, COBOL) and moves to perceived greener pastures. &lt;a href="http://www.zedshaw.com/rants/rails_is_a_ghetto.html"&gt;Zed Shaw did it&lt;/a&gt;, jumping from Ruby to Python, and Mike Gunderloy went from .NET to Rails. &lt;/p&gt;  &lt;p&gt;But it can be difficult to change platform. My clients don’t come to me looking for&amp;#160; a software developer, they come looking for a .NET developer. This is a tragic side effect of big software companies marketing.&lt;/p&gt;  &lt;p&gt;If your &lt;a href="http://www.imdb.com/title/tt0047478/" target="_blank"&gt;village is under attack by bandits&lt;/a&gt;, would you turn away the first seven samurai who offered to help because you didn’t like their swords? What matters is how effectively they can defend your village. &lt;/p&gt;  &lt;p&gt;You should not tell your carpenter what sort of hammer to use and you should not tell your software developer what platform to use. &lt;/p&gt;</description>
      <link>http://hackingon.net/post/Changing-Platform.aspx</link>
      <author>liam.mclennan.nospam@nospam.gmail.com (liammclennan)</author>
      <comments>http://hackingon.net/post/Changing-Platform.aspx#comment</comments>
      <guid>http://hackingon.net/post.aspx?id=c70f1d68-37c0-4f0d-b862-920c8c77ee61</guid>
      <pubDate>Wed, 17 Mar 2010 07:17:25 +1000</pubDate>
      <dc:publisher>liammclennan</dc:publisher>
      <pingback:server>http://hackingon.net/pingback.axd</pingback:server>
      <pingback:target>http://hackingon.net/post.aspx?id=c70f1d68-37c0-4f0d-b862-920c8c77ee61</pingback:target>
      <slash:comments>2</slash:comments>
      <trackback:ping>http://hackingon.net/trackback.axd?id=c70f1d68-37c0-4f0d-b862-920c8c77ee61</trackback:ping>
      <wfw:comment>http://hackingon.net/post/Changing-Platform.aspx#comment</wfw:comment>
      <wfw:commentRss>http://hackingon.net/syndication.axd?post=c70f1d68-37c0-4f0d-b862-920c8c77ee61</wfw:commentRss>
    </item>
    <item>
      <title>Trying to Organise a Software Craftsman Pilgrimage</title>
      <description>&lt;p&gt;As I have &lt;a href="http://hackingon.net/post/My-Message-to-the-Software-Craftsmanship-Group.aspx"&gt;previously written&lt;/a&gt;, I am trying to organise a software craftsman pilgrimage. The idea is to donate some time working with quality developers so that we learn from each other. To be honest I am also trying to &lt;a href="http://media.pragprog.com/titles/cfcar2/worst.pdf" target="_blank"&gt;be the worst&lt;/a&gt;.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;“Always be the worst guy in every band     &lt;br /&gt;you’re in.” Pat Metheny&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;I ended up posting a message to both the software craftsmanship group and the Seattle Alt.NET group and I got a good response from both. I have had discussions with people based in: Seattle, New York, Long Island, Austin and Chicago. Over the next week I have to juggle my schedule and confirm the company(s) I will be spending time with, but the good news is it seems that I will not &lt;a href="http://www.urbandictionary.com/define.php?term=leave%20me%20hanging" target="_blank"&gt;be left hanging&lt;/a&gt;.&lt;/p&gt;</description>
      <link>http://hackingon.net/post/Trying-to-Organise-a-Software-Craftsman-Pilgrimage.aspx</link>
      <author>liam.mclennan.nospam@nospam.gmail.com (liammclennan)</author>
      <comments>http://hackingon.net/post/Trying-to-Organise-a-Software-Craftsman-Pilgrimage.aspx#comment</comments>
      <guid>http://hackingon.net/post.aspx?id=520af33a-a6ea-4e7a-aebb-f4a08160e38f</guid>
      <pubDate>Tue, 16 Mar 2010 19:37:38 +1000</pubDate>
      <dc:publisher>liammclennan</dc:publisher>
      <pingback:server>http://hackingon.net/pingback.axd</pingback:server>
      <pingback:target>http://hackingon.net/post.aspx?id=520af33a-a6ea-4e7a-aebb-f4a08160e38f</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://hackingon.net/trackback.axd?id=520af33a-a6ea-4e7a-aebb-f4a08160e38f</trackback:ping>
      <wfw:comment>http://hackingon.net/post/Trying-to-Organise-a-Software-Craftsman-Pilgrimage.aspx#comment</wfw:comment>
      <wfw:commentRss>http://hackingon.net/syndication.axd?post=520af33a-a6ea-4e7a-aebb-f4a08160e38f</wfw:commentRss>
    </item>
    <item>
      <title>My Message to the Software Craftsmanship Group</title>
      <description>&lt;p&gt;This is a message I &lt;a href="http://groups.google.com/group/software_craftsmanship/browse_thread/thread/adfabef33311159e" target="_blank"&gt;posted to the software craftsmanship group&lt;/a&gt;, looking for a week-long, pairing / skill sharing opportunity in the USA. &lt;/p&gt;  &lt;p&gt;&lt;em&gt;I am a journeyman software craftsman, currently living and working in Brisbane Australia. In April I am going to travel to the US to attend Alt.Net Seattle and Seattle codecamp. &lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;In between the two conferences I have five days in which I would like to undertake a craftsmanship mini-apprenticeship, pairing and skill sharing with your company. I do not require any compensation other than the opportunity to assist you and learn from you. Although my      &lt;br /&gt;conferences are in Seattle I am happy to travel anywhere in the USA and Canada (excluding Hawaii :) ). &lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Things I am good at: .NET web development, javascript, creating software that solves problems      &lt;br /&gt;Things I am learning: Ruby, Rails, javascript &lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;If you are interested in having me as visiting craftsman from the 12th to the 16th of April please reply on this mailing list or contact me directly. &lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Liam McLennan      &lt;br /&gt;&lt;/em&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;Now I wait…&lt;/p&gt;</description>
      <link>http://hackingon.net/post/My-Message-to-the-Software-Craftsmanship-Group.aspx</link>
      <author>liam.mclennan.nospam@nospam.gmail.com (liammclennan)</author>
      <comments>http://hackingon.net/post/My-Message-to-the-Software-Craftsmanship-Group.aspx#comment</comments>
      <guid>http://hackingon.net/post.aspx?id=16382034-38fc-4eb5-87c8-86738f5a72f8</guid>
      <pubDate>Mon, 15 Mar 2010 08:05:26 +1000</pubDate>
      <category>Web Development</category>
      <dc:publisher>liammclennan</dc:publisher>
      <pingback:server>http://hackingon.net/pingback.axd</pingback:server>
      <pingback:target>http://hackingon.net/post.aspx?id=16382034-38fc-4eb5-87c8-86738f5a72f8</pingback:target>
      <slash:comments>3</slash:comments>
      <trackback:ping>http://hackingon.net/trackback.axd?id=16382034-38fc-4eb5-87c8-86738f5a72f8</trackback:ping>
      <wfw:comment>http://hackingon.net/post/My-Message-to-the-Software-Craftsmanship-Group.aspx#comment</wfw:comment>
      <wfw:commentRss>http://hackingon.net/syndication.axd?post=16382034-38fc-4eb5-87c8-86738f5a72f8</wfw:commentRss>
    </item>
    <item>
      <title>Handy Javascript array Extensions – distinct()</title>
      <description>&lt;p&gt;The following code adds a method to javascript arrays that returns a distinct list of values.&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:457e6c65-bd18-413a-99d2-465b781ca14e" style="margin: 0px; padding: 0px; display: inline; float: none;"&gt;
&lt;pre class="brush: jscript; gutter: false; first-line: 1; tab-size: 2;  toolbar: true; "&gt;
Array.prototype.distinct = function() {
    var derivedArray = [];
    for (var i = 0; i &amp;lt; this.length; i += 1) {
        if (!derivedArray.contains(this[i])) {
            derivedArray.push(this[i])
        }
    }
    return derivedArray;
};&lt;/pre&gt;
&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;p&gt;and to demonstrate:&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:b3c9bc11-9461-4b80-a098-a2c415867254" style="margin: 0px; padding: 0px; display: inline; float: none;"&gt;
&lt;pre class="brush: jscript; gutter: false; first-line: 1; tab-size: 2;  toolbar: true; "&gt;
alert([1,1,1,2,2,22,3,4,5,6,7,5,4].distinct().join(','));&lt;/pre&gt;
&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;p&gt;This produces 1,2,22,3,4,5,6,7&lt;/p&gt;
&lt;p&gt;Note that this implementation of distinct() is dependant upon &lt;a href="http://hackingon.net/post/Handy-Javascript-array-Extensions-e28093-contains%28e280a6%29.aspx"&gt;my implementation of contains&lt;/a&gt;.&lt;/p&gt;</description>
      <link>http://hackingon.net/post/Handy-Javascript-array-Extensions-e28093-distinct().aspx</link>
      <author>liam.mclennan.nospam@nospam.gmail.com (liammclennan)</author>
      <comments>http://hackingon.net/post/Handy-Javascript-array-Extensions-e28093-distinct().aspx#comment</comments>
      <guid>http://hackingon.net/post.aspx?id=73790ff8-9e5b-408f-b1f5-376f386b0a9a</guid>
      <pubDate>Fri, 12 Mar 2010 07:32:00 +1000</pubDate>
      <category>Web Development</category>
      <dc:publisher>liammclennan</dc:publisher>
      <pingback:server>http://hackingon.net/pingback.axd</pingback:server>
      <pingback:target>http://hackingon.net/post.aspx?id=73790ff8-9e5b-408f-b1f5-376f386b0a9a</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://hackingon.net/trackback.axd?id=73790ff8-9e5b-408f-b1f5-376f386b0a9a</trackback:ping>
      <wfw:comment>http://hackingon.net/post/Handy-Javascript-array-Extensions-e28093-distinct().aspx#comment</wfw:comment>
      <wfw:commentRss>http://hackingon.net/syndication.axd?post=73790ff8-9e5b-408f-b1f5-376f386b0a9a</wfw:commentRss>
    </item>
    <item>
      <title>Handy Javascript array Extensions – contains(…)</title>
      <description>&lt;p&gt;This javascript adds a method to javascript arrays that returns a boolean indicating if the supplied object is an element of the array&amp;nbsp;
&lt;pre class="brush: jscript; gutter: false; first-line: 1; tab-size: 2;  toolbar: true; "&gt;
Array.prototype.contains = function(item) {
    for (var i = 0; i &amp;lt; this.length; i += 1) {
        if (this[i] === item) {
            return true;
        }
    }
    return false;
};&amp;nbsp;&lt;/pre&gt;
&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/p&gt;
&lt;p&gt;To test&lt;/p&gt;
&lt;div style="margin: 0px; padding: 0px; display: inline; float: none;" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:d530d9ea-5c96-40b8-9201-fd21cc6b15da" class="wlWriterEditableSmartContent"&gt;
&lt;pre class="brush: jscript; gutter: false; first-line: 1; tab-size: 2;  toolbar: true; "&gt;
alert([1,1,1,2,2,22,3,4,5,6,7,5,4].contains(2)); // true
alert([1,1,1,2,2,22,3,4,5,6,7,5,4].contains(99)); // false&lt;/pre&gt;
&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;</description>
      <link>http://hackingon.net/post/Handy-Javascript-array-Extensions-e28093-contains(e280a6).aspx</link>
      <author>liam.mclennan.nospam@nospam.gmail.com (liammclennan)</author>
      <comments>http://hackingon.net/post/Handy-Javascript-array-Extensions-e28093-contains(e280a6).aspx#comment</comments>
      <guid>http://hackingon.net/post.aspx?id=a00d9f26-f1b8-42a5-91b1-490c3140d0b8</guid>
      <pubDate>Thu, 11 Mar 2010 14:29:00 +1000</pubDate>
      <category>Web Development</category>
      <dc:publisher>liammclennan</dc:publisher>
      <pingback:server>http://hackingon.net/pingback.axd</pingback:server>
      <pingback:target>http://hackingon.net/post.aspx?id=a00d9f26-f1b8-42a5-91b1-490c3140d0b8</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://hackingon.net/trackback.axd?id=a00d9f26-f1b8-42a5-91b1-490c3140d0b8</trackback:ping>
      <wfw:comment>http://hackingon.net/post/Handy-Javascript-array-Extensions-e28093-contains(e280a6).aspx#comment</wfw:comment>
      <wfw:commentRss>http://hackingon.net/syndication.axd?post=a00d9f26-f1b8-42a5-91b1-490c3140d0b8</wfw:commentRss>
    </item>
    <item>
      <title>Sneaky Javascript For Loop Bug</title>
      <description>&lt;p&gt;Javascript allows you to declare variables simply by assigning a value to an identify, in the same style as ruby:&lt;/p&gt;
&lt;div style="margin: 0px; padding: 0px; display: inline; float: none;" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:4a05554b-5f92-43d9-a146-73b39bbe7bd3" class="wlWriterEditableSmartContent"&gt;
&lt;pre class="brush: jscript; gutter: false; first-line: 1; tab-size: 2;  toolbar: true; "&gt;
myVar = &amp;quot;some text&amp;quot;;&lt;/pre&gt;
&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;p&gt;Good javascript developers know that this is a bad idea because undeclared variables are assigned to the global object, usually window, making myVar globally visible. So the above code is equivalent to:&lt;/p&gt;
&lt;div style="margin: 0px; padding: 0px; display: inline; float: none;" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:5f6ec084-948a-4924-b278-2ac696865866" class="wlWriterEditableSmartContent"&gt;
&lt;pre class="brush: jscript; gutter: false; first-line: 1; tab-size: 2;  toolbar: true; "&gt;
window.myVar = &amp;quot;some text&amp;quot;;&lt;/pre&gt;
&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;p&gt;What I did not realise is that this applies to for loop initialisation as well.&lt;/p&gt;
&lt;div style="margin: 0px; padding: 0px; display: inline; float: none;" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:c0a507b4-a3c3-40fd-bb38-6ea7ebfbdf2c" class="wlWriterEditableSmartContent"&gt;
&lt;pre class="brush: jscript; gutter: false; first-line: 1; tab-size: 2;  toolbar: true; "&gt;
for (i = 0; i &amp;lt; myArray.length; i += 1) {

}

// is equivalent to


for (window.i = 0; window.i &amp;lt; myArray.length; window.i += 1) {

}&lt;/pre&gt;
&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;p&gt;Combine this with function calls nested inside of the for loops and you get some very strange behaviour, as the value of i is modified simultaneously by code in different scopes. The moral of the story is to ALWAYS declare javascript variables with the var keyword, even when intialising a for loop. This way i is scoped to the current function.&lt;/p&gt;
&lt;div style="margin: 0px; padding: 0px; display: inline; float: none;" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:04d13013-7768-49f1-a9b0-7c0bc2b021b8" class="wlWriterEditableSmartContent"&gt;
&lt;pre class="brush: jscript; gutter: false; first-line: 1; tab-size: 2;  toolbar: true; "&gt;
for (var i = 0; i &amp;lt; myArray.length; i += 1) {

}&lt;/pre&gt;
&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;</description>
      <link>http://hackingon.net/post/Sneaky-Javascript-For-Loop-Bug.aspx</link>
      <author>liam.mclennan.nospam@nospam.gmail.com (liammclennan)</author>
      <comments>http://hackingon.net/post/Sneaky-Javascript-For-Loop-Bug.aspx#comment</comments>
      <guid>http://hackingon.net/post.aspx?id=85f41245-e634-43b5-bbfe-4fc56fb09fc0</guid>
      <pubDate>Wed, 10 Mar 2010 12:57:00 +1000</pubDate>
      <category>Web Development</category>
      <dc:publisher>liammclennan</dc:publisher>
      <pingback:server>http://hackingon.net/pingback.axd</pingback:server>
      <pingback:target>http://hackingon.net/post.aspx?id=85f41245-e634-43b5-bbfe-4fc56fb09fc0</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://hackingon.net/trackback.axd?id=85f41245-e634-43b5-bbfe-4fc56fb09fc0</trackback:ping>
      <wfw:comment>http://hackingon.net/post/Sneaky-Javascript-For-Loop-Bug.aspx#comment</wfw:comment>
      <wfw:commentRss>http://hackingon.net/syndication.axd?post=85f41245-e634-43b5-bbfe-4fc56fb09fc0</wfw:commentRss>
    </item>
    <item>
      <title>Documenting the Success Scenario</title>
      <description>&lt;p&gt;Posts like my &lt;a href="http://hackingon.net/post/jQuery-client-side-templates-with-jqote-and-AspNet-MVC.aspx"&gt;intro to jQuery client-side templates&lt;/a&gt; may appear, at first glance, to add nothing to the existing body of knowledge. However, the trouble that I regularly encounter with technical documentation is that the author tries too hard to be exhaustive. When first approaching a new topic the reader is most interested in the success scenario. Under normal conditions, how would I use this technology? What is the most basic syntax?&lt;/p&gt;
&lt;p&gt;A great example of documentation that focuses on the core usage of a technology is Joel Spolsky&amp;rsquo;s excellent &lt;a target="_blank" href="http://hginit.com"&gt;Hg Init&lt;/a&gt;. The top level topics are: Subversion Re-education, Ground up Mercurial, Setting up for a Team, Fixing Goofs, Merging and Repository Architecture. These are exactly the things I want to know about as a Hg newbie.&lt;/p&gt;
&lt;p&gt;Much as we describe software functionality with user stories, the best introductory documentation is grouped by &amp;lsquo;what is the reader trying to do&amp;rsquo;, instead of alphabetical or chronological groupings. Once the reader has a working knowledge of the topic then exhaustive reference documentation becomes useful.&lt;/p&gt;</description>
      <link>http://hackingon.net/post/Documenting-the-Success-Scenario.aspx</link>
      <author>liam.mclennan.nospam@nospam.gmail.com (liammclennan)</author>
      <comments>http://hackingon.net/post/Documenting-the-Success-Scenario.aspx#comment</comments>
      <guid>http://hackingon.net/post.aspx?id=a0a0d14a-1665-4fb4-8a49-6c655f0170bc</guid>
      <pubDate>Thu, 04 Mar 2010 11:07:00 +1000</pubDate>
      <category>Web Development</category>
      <dc:publisher>liammclennan</dc:publisher>
      <pingback:server>http://hackingon.net/pingback.axd</pingback:server>
      <pingback:target>http://hackingon.net/post.aspx?id=a0a0d14a-1665-4fb4-8a49-6c655f0170bc</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://hackingon.net/trackback.axd?id=a0a0d14a-1665-4fb4-8a49-6c655f0170bc</trackback:ping>
      <wfw:comment>http://hackingon.net/post/Documenting-the-Success-Scenario.aspx#comment</wfw:comment>
      <wfw:commentRss>http://hackingon.net/syndication.axd?post=a0a0d14a-1665-4fb4-8a49-6c655f0170bc</wfw:commentRss>
    </item>
    <item>
      <title>jQuery client-side templates with jqote and Asp.Net MVC</title>
      <description>&lt;h2&gt;Why Use Client-side Javascript Templates?&lt;/h2&gt;
&lt;p&gt;When building rich internet applications you often need to construct html on the client. I am going to demonstrate how to construct DOM elements using the &lt;a target="_blank" href="http://plugins.jquery.com/project/jqote"&gt;jqote jQuery plugin&lt;/a&gt; (2.0.0).&lt;/p&gt;
&lt;p&gt;The naive approach to client-side html generation is to embed html inside javascript like:&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:30fbb1e1-e96b-4fa4-a738-f4d566df8e1b" style="margin: 0px; padding: 0px; display: inline; float: none;"&gt;
&lt;pre class="brush: jscript; gutter: false; first-line: 1; tab-size: 2;  toolbar: true; "&gt;
var text = 'Some text';
$('body').append($('&amp;lt;div id=&amp;quot;content&amp;gt;' + text + '&amp;lt;/div&amp;gt;&amp;quot;'));&lt;/pre&gt;
&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;p&gt;This approach fails as the complexity of the html increases. It is also a clear separation of concerns violation to mix html (presentation) with script (interaction).&lt;/p&gt;
&lt;p&gt;Javascript templates provide a way to dynamically build html on the client while storing the dynamic html with the rest of the presentation markup. Additionally javascript templates provide MVC-like separation of concerns.&lt;/p&gt;
&lt;h2&gt;Dynamically Building a Table with a Client-side Javascript Template&lt;/h2&gt;
&lt;p&gt;Suppose you want a web page that allows the user to build a table of people. For each person the user can enter their name and age. First we need a form to collect the values, and we need some jQuery magic to cancel the form post:&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:8a3c6d50-0c12-4d2e-86dd-49405934433d" style="margin: 0px; padding: 0px; display: inline; float: none;"&gt;
&lt;pre class="brush: jscript; gutter: false; first-line: 1; tab-size: 2;  toolbar: true; "&gt;
&amp;lt;form id=&amp;quot;people_input&amp;quot;&amp;gt;
        &amp;lt;label for=&amp;quot;name&amp;quot;&amp;gt;Name: &amp;lt;/label&amp;gt;&amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;name&amp;quot; /&amp;gt;&amp;lt;br /&amp;gt;
        &amp;lt;label for=&amp;quot;age&amp;quot;&amp;gt;Age: &amp;lt;/label&amp;gt;&amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;age&amp;quot; /&amp;gt;&amp;lt;br /&amp;gt;
        &amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;Add&amp;quot; /&amp;gt;
    &amp;lt;/form&amp;gt;

    &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;

        $(document).ready(function () {

            $('form#people_input').submit(function (e) {
                e.preventDefault();
            });

        });    
    
    &amp;lt;/script&amp;gt;&lt;/pre&gt;
&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;p&gt;There needs to be a table to display the people, and each time the form is submitted a new row should be added to the table. jqote templates are defined in the html by wrapping the template in a script tag and a CDATA tag. The script tag is necessary to stop the template from being interpreted as part of the page. The CDATA tag is required so that the page remains syntactically valid. Here is my empty table and a template for a row:&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:828adaa1-87bd-44fe-9bee-df15f158aeea" style="margin: 0px; padding: 0px; display: inline; float: none;"&gt;
&lt;pre class="brush: jscript; gutter: false; first-line: 1; tab-size: 2;  toolbar: true; "&gt;
&amp;lt;table id=&amp;quot;person_table&amp;quot;&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;th&amp;gt;Name&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Age&amp;lt;/th&amp;gt;
        &amp;lt;/tr&amp;gt;    
    &amp;lt;/table&amp;gt;

    &amp;lt;script type=&amp;quot;text/html&amp;quot; id=&amp;quot;template&amp;quot;&amp;gt;
    &amp;lt;![CDATA[
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;&amp;lt;$= this.name $&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;$= this.age $&amp;gt;&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;    
    ]]&amp;gt;
    &amp;lt;/script&amp;gt;&lt;/pre&gt;
&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The default jqote tags use &amp;lt;%= %&amp;gt; syntax which I have replaced with &amp;lt;$= $&amp;gt; to avoid conflict with Asp.Net MVC. Inside of a jqote template &amp;lsquo;this&amp;rsquo; refers to the data object used to render the template. Within the jqote tags any javascript is valid since jqote is based on John Resig&amp;rsquo;s &lt;a target="_blank" href="http://ejohn.org/blog/javascript-micro-templating/"&gt;Javascript Micro-Templating&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The final, and most interesting step is to render the template each time the form is submitted and insert the result at the end of the table. Note the second parameter to the jqote() method, which is the character to use for the html nugget syntax.&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:284618f6-bd82-4466-9cc2-3478f3885217" style="margin: 0px; padding: 0px; display: inline; float: none;"&gt;
&lt;pre class="brush: jscript; gutter: false; first-line: 1; tab-size: 2;  toolbar: true; "&gt;
        $(document).ready(function () {

            $('form#people_input').submit(function (e) {
                var data = { name: $('input[name=name]').val(), age: $('input[name=age]').val() };
                $('table#person_table').append($('#template').jqote(data, '$'));
                e.preventDefault();
            });

        });   &lt;/pre&gt;
&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;p&gt;To try out the complete code, grab it from &lt;a target="_blank" href="http://codepaste.net/a8oac9"&gt;codepaste.net&lt;/a&gt;.&lt;/p&gt;</description>
      <link>http://hackingon.net/post/jQuery-client-side-templates-with-jqote-and-AspNet-MVC.aspx</link>
      <author>liam.mclennan.nospam@nospam.gmail.com (liammclennan)</author>
      <comments>http://hackingon.net/post/jQuery-client-side-templates-with-jqote-and-AspNet-MVC.aspx#comment</comments>
      <guid>http://hackingon.net/post.aspx?id=96d07d69-8e0a-4a53-9087-79bc52a7cb0a</guid>
      <pubDate>Wed, 03 Mar 2010 17:48:00 +1000</pubDate>
      <category>Web Development</category>
      <dc:publisher>liammclennan</dc:publisher>
      <pingback:server>http://hackingon.net/pingback.axd</pingback:server>
      <pingback:target>http://hackingon.net/post.aspx?id=96d07d69-8e0a-4a53-9087-79bc52a7cb0a</pingback:target>
      <slash:comments>1</slash:comments>
      <trackback:ping>http://hackingon.net/trackback.axd?id=96d07d69-8e0a-4a53-9087-79bc52a7cb0a</trackback:ping>
      <wfw:comment>http://hackingon.net/post/jQuery-client-side-templates-with-jqote-and-AspNet-MVC.aspx#comment</wfw:comment>
      <wfw:commentRss>http://hackingon.net/syndication.axd?post=96d07d69-8e0a-4a53-9087-79bc52a7cb0a</wfw:commentRss>
    </item>
    <item>
      <title>Looking at Languages (C#, Javascript &amp; Ruby) 3: Classes</title>
      <description>&lt;p&gt;Javascript does not have classes in the traditional sense, but we can achieve something similar in a number of ways. C# and Ruby both have standard class syntax.&lt;/p&gt;
&lt;p&gt;This post is part of a series comparing the language features of the C#, Javascript and Ruby programming languages.&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;a target="_blank" href="http://hackingon.net/post/Looking-at-Languages-(C-Javascript-Ruby)-1-Installation-and-hello-world.aspx"&gt;Part 1: Installation and hello world&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a target="_blank" href="http://hackingon.net/post/Looking-at-Languages-%28C-Javascript-Ruby%29-2-Variables.aspx"&gt;Part 2: Variables&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a target="_blank" href="http://hackingon.net/post/Looking-at-Languages-(C-Javascript-Ruby)-3-Classes.aspx"&gt;Part 3: Classes&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;C#&lt;/h3&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:5a04c201-5c32-454c-9be9-2abd2c89dfcb" style="margin: 0px; padding: 0px; display: inline; float: none;"&gt;
&lt;pre style="overflow: visible; background-color: rgb(255, 255, 255);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Vehicle&lt;br /&gt;    {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;protected&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Make { &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;; }&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;protected&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Model { &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;; }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Vehicle(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; make, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; model)&lt;br /&gt;        {&lt;br /&gt;            Make &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; make;&lt;br /&gt;            Model &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; model;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;virtual&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Print()&lt;br /&gt;        {&lt;br /&gt;            Console.WriteLine(GetDescription());&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;protected&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; GetDescription()&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; string formatting syntax&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;.Format(&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Make: {0}  Model: {1}&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, Make, Model);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Helicopter : Vehicle   &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; inheritance syntax&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;    {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; NumberOfRotorBlades { &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;; }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Helicopter(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; numberOfRotorBlades, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; make, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; model)&lt;br /&gt;            : &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;base&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(make, model)&lt;br /&gt;        {&lt;br /&gt;            NumberOfRotorBlades &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; numberOfRotorBlades;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;override&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Print()&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; string concatenation syntax&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;            Console.WriteLine(GetDescription() &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt; Number of Rotor Blades:&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; NumberOfRotorBlades);&lt;br /&gt;        }&lt;br /&gt;    }&lt;/span&gt;&lt;/pre&gt;
&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h3&gt;Javascript&lt;/h3&gt;
&lt;p&gt;Class:&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:8654a3ae-b534-436b-9296-62957eb45b7a" style="margin: 0px; padding: 0px; display: inline; float: none;"&gt;
&lt;pre style="overflow: auto; background-color: rgb(255, 255, 255);"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; declare vehicle 'class'&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; vehicle &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(seed) {&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; that &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; {};&lt;br /&gt;  &lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; private method  &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; getDescription &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;() {&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Make: &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; seed.make &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;  Model: &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; seed.model;&lt;br /&gt;  };&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; public method&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;  that.print &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;() {&lt;br /&gt;    alert(getDescription());&lt;br /&gt;  };&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; that;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; instantiate a vehicle&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; magna &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; vehicle({&lt;br /&gt;  make: &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;'&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Mitsubishi&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;'&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;,&lt;br /&gt;  model: &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;'&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Magna&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;'&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; });  magna.print(); &lt;/span&gt;&lt;/pre&gt;
&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;p&gt;Derived class:&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:48cd171f-a01a-4c2e-92df-ae1479274226" style="margin: 0px; padding: 0px; display: inline; float: none;"&gt;
&lt;pre style="overflow: auto; background-color: rgb(255, 255, 255);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; declare helicopter 'class'&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; helicopter &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(seed) {&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; that &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; {};&lt;br /&gt;  that.prototype &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; vehicle(seed);&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; getDescription &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;() {&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Make: &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; seed.make &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;  Model: &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; seed.model;&lt;br /&gt;  };&lt;br /&gt;  &lt;br /&gt;  that.print &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;() {&lt;br /&gt;    alert(getDescription() &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Number of Rotor Blades:&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; seed.numberOfRotorBlades);&lt;br /&gt;  };&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; that;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; instantiate a helicopter&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; ah64 &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; helicopter({&lt;br /&gt;  make: &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;'&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Hughes Helicopters&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;'&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;,&lt;br /&gt;  model: &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;'&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;AH-64&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;'&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;,&lt;br /&gt;  numberOfRotorBlades: &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;4&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; });  ah64.print(); &lt;/span&gt;&lt;/pre&gt;
&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;h3&gt;Ruby&lt;/h3&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:ed8e982b-400f-4a69-aafe-f970e23ceaa6" style="margin: 0px; padding: 0px; display: inline; float: none;"&gt;
&lt;pre style="overflow: auto; background-color: rgb(255, 255, 255);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; class Vehicle    def initialize(make, model)     @make = make&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;    @model = model&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;  end&lt;br /&gt;&lt;br /&gt;  def print&lt;br /&gt;    puts get_description&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;private&lt;br /&gt;&lt;br /&gt;  def get_description&lt;br /&gt;    return &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Make: #{@make} Model: #{@model}&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;   end  end  magna = Vehicle.new(&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;'&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Mitsubishi&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;'&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;'&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Magna&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;'&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;br /&gt;magna.print&lt;br /&gt;&lt;br /&gt;class Helicopter &amp;lt; Vehicle&lt;br /&gt;&lt;br /&gt;  def initialize(make, model, number_of_rotors)&lt;br /&gt;    super(make, model)&lt;br /&gt;    @number_of_rotors = number_of_rotors&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  def print&lt;br /&gt;    puts get_description + &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt; Number of Rotors: #{@number_of_rotors}&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;   end  end  ah64 = Helicopter.new(&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Hughes Helicopters&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;AH-64&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(128, 0, 128);"&gt;4&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;br /&gt;ah64.print&lt;/span&gt;&lt;/pre&gt;
&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;</description>
      <link>http://hackingon.net/post/Looking-at-Languages-(C-Javascript-Ruby)-3-Classes.aspx</link>
      <author>liam.mclennan.nospam@nospam.gmail.com (liammclennan)</author>
      <comments>http://hackingon.net/post/Looking-at-Languages-(C-Javascript-Ruby)-3-Classes.aspx#comment</comments>
      <guid>http://hackingon.net/post.aspx?id=47065898-9597-4d71-8fd3-30f6d71dc70a</guid>
      <pubDate>Fri, 27 Nov 2009 09:04:00 +1000</pubDate>
      <category>Web Development</category>
      <dc:publisher>liammclennan</dc:publisher>
      <pingback:server>http://hackingon.net/pingback.axd</pingback:server>
      <pingback:target>http://hackingon.net/post.aspx?id=47065898-9597-4d71-8fd3-30f6d71dc70a</pingback:target>
      <slash:comments>1</slash:comments>
      <trackback:ping>http://hackingon.net/trackback.axd?id=47065898-9597-4d71-8fd3-30f6d71dc70a</trackback:ping>
      <wfw:comment>http://hackingon.net/post/Looking-at-Languages-(C-Javascript-Ruby)-3-Classes.aspx#comment</wfw:comment>
      <wfw:commentRss>http://hackingon.net/syndication.axd?post=47065898-9597-4d71-8fd3-30f6d71dc70a</wfw:commentRss>
    </item>
  </channel>
</rss>
