<?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>Platformability &#187; JavaScript</title>
	<atom:link href="http://blog.caplin.com/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.caplin.com</link>
	<description>Single Dealer Platforms, Industry Expertise</description>
	<lastBuildDate>Fri, 03 Feb 2012 15:38:56 +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>Dart: did Google miss the bull&#8217;s-eye?</title>
		<link>http://blog.caplin.com/2011/10/17/dart-did-google-miss-the-bulls-eye/</link>
		<comments>http://blog.caplin.com/2011/10/17/dart-did-google-miss-the-bulls-eye/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 08:52:12 +0000</pubDate>
		<dc:creator>Amir Hajizamani</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Software Architecture]]></category>
		<category><![CDATA[Dart]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[Programming Language]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://blog.caplin.com/?p=7265</guid>
		<description><![CDATA[The vocal portions of the Web that care about such things seem to have already made up their minds about Dart, the new web programming language from Google. My opinion of it has been flipping between intrigue and tedium. Maybe you don&#8217;t even know what I&#8217;m talking about so here&#8217;s...]]></description>
			<content:encoded><![CDATA[<p><a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cuY2FwbGluLmNvbS93cC1jb250ZW50L3VwbG9hZHMvZGFydC1sb2dvLnBuZw=="><img class="alignright size-full wp-image-7267" src="http://blog.caplin.com/wp-content/uploads/dart-logo.png" alt="Dart Programming Language Logo" width="268" height="116" /></a></p>
<p>The vocal portions of the Web that care about such things seem to have already made up their minds about Dart, the new web programming language from Google. My opinion of it has been flipping between intrigue and tedium.</p>
<p>Maybe you don&#8217;t even know what I&#8217;m talking about so here&#8217;s the gist of it: last week at the <a  0="title="GOTO" 1="-" 2="Aarhus" 3="2011"" href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2dvdG9jb24uY29tL2Fhcmh1cy0yMDExLw==" 4="target="_blank"">GOTO conference</a> Google unveiled, to moderate hype, their new programming language called <a  0="title="Official" 1="Dart" 2="Programming" 3="Language" 4="website"" href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5kYXJ0bGFuZy5vcmcv" 5="target="_blank"">Dart</a>. The official aim of Dart is to help developers with writing &#8220;structured web applications&#8221; &#8211; which sounds like a euphemism for &#8220;[eventually] replace JavaScript&#8221; &#8212; to some at least. I&#8217;m going to explore that loaded sentence (or go to <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=I3RsZHI=">tl;dr</a>).</p>
<h2>Origins of Dart at Google</h2>
<p>Google and the Web are inseparable. To many, the Web would pretty much cease to be useful without Google Search and Gmail. Google pioneered, or at least popularised, the foundations of modern web application development, namely <abbr title="Asynchronous JavaScript and XML">AJAX</abbr>. When Google Maps was released it was a breath of fresh air in its product niche and an astounding achievement in programming and UX. The thing to note here is the J in AJAX, which stands for JavaScript. Having wedded itself to the Web, Google has had to wrestle with this piece of technology since the beginning of its forays into anything more complicated that a search box and a list of results.</p>
<p>I doubt a Google spokesperson has ever come out to say it, but it&#8217;s clear that Google staff are no fans of JavaScript. Six years ago, they got sick of figuring out the look and feel of things and started work on <a  0="title="Google" 1="Web" 2="Toolkit"" href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2NvZGUuZ29vZ2xlLmNvbS93ZWJ0b29sa2l0Lw==" 3="target="_blank"">GWT</a>. A few years later they got fed up of the performance of JavaScript runtimes and wrote the source-to-source <a  0="title="Closure" 1="Compiler"" href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2NvZGUuZ29vZ2xlLmNvbS9jbG9zdXJlLw==" 2="target="_blank"">Closure Compiler/Optimiser</a> for JavaScript and started work on their own <a  0="title="Google's" 1="V8" 2="JavaScript" 3="Engine"" href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2NvZGUuZ29vZ2xlLmNvbS9wL3Y4Lw==" 4="target="_blank"">V8 JavaScript Engine</a> which powers Google Chrome (and notably also NodeJS). All in all, a business expense of at least <a  0="title="Summary" 1="of" 2="Google's" 3="JavaScript-related" 4="projects'" 5="codebases."" href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cHM6Ly93d3cub2hsb2gubmV0L3AvY29tcGFyZT9wcm9qZWN0XzA9R29vZ2xlK1dlYitUb29sa2l0JmFtcDtwcm9qZWN0XzE9Q2xvc3VyZStDb21waWxlciZhbXA7cHJvamVjdF8yPUdvb2dsZStWOCtKYXZhU2NyaXB0K0VuZ2luZQ==" 6="target="_blank"">tens of millions of dollars</a>, not to mention the headaches and opportunity cost. Of course, Google has to go all this effort because of the scale of their JavaScript codebase, which makes any criticism from small- to medium-sized development teams utterly moot when they say &#8220;we&#8217;ve never had a problem with normal JavaScript&#8221; &#8212; yes, of course you haven&#8217;t, because you&#8217;re not juggling a web application product line which includes Gmail and Google Docs.</p>
<p><a  0="title="Mark" 1="Miller's" 2="leaked" 3="email" 4="about" 5="the" 6="Future" 7="of" 8="JavaScript"" href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3Bhc3RlYmluLmNvbS9OVU1UVHJLag==" 9="target="_blank"">This leaked email</a> from Googler and ECMAScript committee member Mark Miller emerged last year. It provides an insight into Google&#8217;s view of JavaScript as a bottleneck in their efforts to build products that compete with native applications. It&#8217;s a long read but the gist of is that Google can either wait for JavaScript to evolve slowly, and/or take action and write its own better JavaScript, codenamed &#8220;Dash&#8221; in the email. The main goals of the new language are listed as performance, developer usability (including familiarity) and improved tooling (a.k.a. clearer code structuring and packaging), which no-one will deny are lacking in JavaScript.</p>
<p>So they did just that. Sort of.</p>
<h3>Dear Google, Public Relations != Developer Relations</h3>
<p><span style="font-weight: normal;">&lt;rant&gt;</span></p>
<p><span style="font-weight: normal;">Google suffers from <a  0="title="Not-Invented-Here"" href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9OSUhfc3luZHJvbWU=" 1="target="_blank"">NIH Syndrome</a>: it does not take from the outside world, preferring to build its tools from scratch, and anything it produces it does so mainly for consumption by the thousands of people it employs (this manifests itself in things like their <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cuY2FwbGluLmNvbS8yMDExLzEwLzEzL2l0cy1hbGwtYWJvdXQtcGxhdGZvcm1zLw==">approach to Platform development</a>, too). Don&#8217;t let the odd open-sourced project fool you. </span></p>
<p><span style="font-weight: normal;">In the case of Dart (<a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2dvbGFuZy5vcmcv" 0="target="_blank"">not the first Google-made langauge</a>) they may have hyped up its announcement, but they clearly have no intention of letting programmers &#8212; the only people who care &#8212; actually experiment with the new language yet. When you go to <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2NvZGUuZ29vZ2xlLmNvbS9wL2RhcnQv" 0="target="_blank"">Dart&#8217;s code repository</a>, there is little effort made to make it simple for you build and use anything. Maybe Dart is just not ready for too much public airing, but that means they should have left its unveiling until it was. Google is not providing a pre-built compiler or VM binary for Dart, and <a  0="title="Build," 1="stage" 2="0"" href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2NvZGUuZ29vZ2xlLmNvbS9wL2RhcnQvd2lraS9HZXR0aW5nVGhlU291cmNl" 3="target="_blank"">their</a> <a  0="title="Build," 1="stage" 2="1"" href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2NvZGUuZ29vZ2xlLmNvbS9wL2RhcnQvd2lraS9QcmVwYXJpbmdZb3VyTWFjaGluZQ==" 3="target="_blank"">build</a> <a  0="title="Build," 1="stage" 2="2"" href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2NvZGUuZ29vZ2xlLmNvbS9wL2RhcnQvd2lraS9CdWlsZGluZw==" 3="target="_blank"">instructions</a> are just about tedious enough that I&#8217;d rather not waste my time. If <code>git clone</code> and <code>make install</code> are good enough for many a large project, why am I being instructed to install and use a Google-specific tool to merely fetch code?! No thanks.</span></p>
<p>&lt;/rant&gt;</p>
<h2>What&#8217;s Dart Like?</h2>
<p>Apart from <a  0="title="Overview" 1="of" 2="Dart"" href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5kYXJ0bGFuZy5vcmcvZG9jcy90ZWNobmljYWwtb3ZlcnZpZXcvaW5kZXguaHRtbA==" 3="target="_blank"">syntax and code samples</a> that run in the browser, there isn&#8217;t much to go on. I quite like <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5yZWFkd3JpdGV3ZWIuY29tL2hhY2svMjAxMS8xMC9kYXJ0LWlzLXRvLWphdmFzY3JpcHQtYXMtYy1pcy5waHA=" 0="target="_blank"">this article</a> that says Dart is to JavaScript what C# is to C++: basically cleaning up some of the mess. Here&#8217;s a summary of what I think are the main features to give you a feel.</p>
<h3>Key Language Features</h3>
<h4>Purely class-based</h4>
<p>The class and interface concepts from Java are brought into Dart, almost exactly, with multiple inheritance being achieved through implementing several interfaces. The &#8220;purity&#8221; here refers to the idea of everything-has-a-class (or everything-is-an-object), which is lacking in both Java and JavaScript, and can only be a good thing. This applies to functions, of course, which makes closures possible in the same way as JavaScript. Compared to JavaScript&#8217;s <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9Qcm90b3R5cGUtYmFzZWQ=" 0="target="_blank"">prototype-based</a> model of OOP this class-based approach makes writing Dart code less crufty, more familiar to the average programmer, and will make tooling and dealing with hierarchy of the code simpler or at least easier to adapt from existing tools.</p>
<p>I suspect this model improves the run-time performance of Dart code compared to JavaScript, too, since JavaScript&#8217;s prototypal inheritance and functions-as-objects idiom are expensive (objects are cloned or recreated instead of referenced or re-used), at least without a good JIT compiler (but don&#8217;t hold me to that).</p>
<h4>Optional typing</h4>
<p>This is one of the more baffling features for me. You could write Dart code without any consideration for variable types, but you could also annotate your variables with types, like String or any class you&#8217;ve defined. The baffling nature of this is that the annotation is just that, an annotation: it makes no difference to how your code works, other than the compiler giving you a warning if you&#8217;ve misused the variable (e.g. tried to assign a number to a String variable). The code will still compile and run.</p>
<p>The justification for this feature is that it provides &#8220;documentation&#8221; and aids debugging and static build tools during development. I&#8217;m not convinced by this half-feature. Perhaps the makers didn&#8217;t want to put off web developers with scary strong typing or the goal of making Dart compilable to JavaScript was an obstacle. The <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5kYXJ0bGFuZy5vcmcvYXJ0aWNsZXMvb3B0aW9uYWwtdHlwZXMvI3VzaW5nLXR5cGVz" 0="target="_blank"">official advice</a> is &#8220;use types where they make sense&#8221;. To me, that advice doesn&#8217;t make sense.</p>
<h4>Structure and isolation</h4>
<p>One of the big practical difference between JavaScript and Dart is that when embedded in HTML, each script tag containing Dart code is isolated and can not access other scripts directly, i.e. there is no per-page global namespace. Also, Dart code isn&#8217;t simply run when it is encountered but a main() function needs to be included as the entry point into each piece of code. In theory, the designers intend each portion of code, or <em>isolate</em>, to be able to run in its own thread, but such multi-threading support is non-existent in browsers.</p>
<p>This is where the &#8220;structured&#8221; nature of Dart is most obvious and I personally like it compared to JavaScript, but those used to the way JavaScript behaves will resist it.</p>
<p>In the language specification, there is some detail about the concurrency model of Dart, which involves these isolates behaving like <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9BY3Rvcl9tb2RlbA==" 0="target="_blank"">actors</a> which perform local computation and then communicate via message-passing. I didn&#8217;t spend much time trying to understand these, but <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2dzLnBlcmwub3JnL3VzZXJzL3JhZmFlbF9nYXJjaWEtc3VhcmV6LzIwMTEvMTAvd2h5LWRhcnQtaXMtbm90LXRoZS1sYW5ndWFnZS1vZi10aGUtZnV0dXJlLmh0bWw=" 0="target="_blank"">this (rather negative) write-up</a> has an explanation.</p>
<h2><span>Why you won&#8217;t use Dart</span></h2>
<p>Firstly, there is obviously no practical implementation for developing or deploying Dart code, so don&#8217;t waste your time on it yet. Even the Google Chrome team aren&#8217;t 100% on whether and when they will implement a Dart runtime, let alone other browser vendors.</p>
<p>Secondly, although all concepts used in Dart should be familiar, it is still a paradigm shift for web developers and you can get by just fine with JavaScript. This extends to the way Dart handles DOM events which is something many developers take some time to completely absorb even in JavaScript with all the online documentation available, let alone with Dart&#8217;s event model.</p>
<p>Thirdly, if you really don&#8217;t want to write in JavaScript, and you don&#8217;t have Google&#8217;s NIH Syndrome, you already have access to many well-established <a  0="title="altJS"" href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2FsdGpzLm9yZy8=" 1="target="_blank"">alternatives</a>. I have written a non-trivial amount of code in <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2phc2hrZW5hcy5naXRodWIuY29tL2NvZmZlZS1zY3JpcHQv" 0="target="_blank"">CoffeeScript</a>, which is a pleasure to use, and look forward to playing more with <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cHM6Ly9naXRodWIuY29tL2Nsb2p1cmUvY2xvanVyZXNjcmlwdA==" 0="target="_blank"">ClojureScript</a>, which is elegant but still immature. Of course, JavaScript isn&#8217;t just &#8220;assembly language for the Web&#8221; which can be ignored and you still need to fully understand its intricacies before trying to work around it.</p>
<h2 id="tldr">tl;dr</h2>
<p><a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3Byb2dyYW1tZXJzLnN0YWNrZXhjaGFuZ2UuY29tL3F1ZXN0aW9ucy8xMTQwOTQvZ29vZ2xlLWRhcnQtdnMtY29mZmVlc2NyaXB0LXdoaWNoLW9uZS1zaG91bGQtb25lLWxlYXJuLzExNDA5OSMxMTQwOTk=" 0="target="_blank"">This chap on StackOverflow</a> got it right, in my opinion: <em>Learn JavaScript, use CoffeeScript, check out Dart.</em></p>
 <img src="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=7265" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.caplin.com/2011/10/17/dart-did-google-miss-the-bulls-eye/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>What I Learnt at SPA 2011</title>
		<link>http://blog.caplin.com/2011/06/17/what-i-learnt-at-spa-2011/</link>
		<comments>http://blog.caplin.com/2011/06/17/what-i-learnt-at-spa-2011/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 13:05:00 +0000</pubDate>
		<dc:creator>Ian Alderson</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://blog.caplin.com/?p=6747</guid>
		<description><![CDATA[After weeks of keen anticipation, not to mention many long nights of preparation for my own session, SPA 2011 has now been and gone. Overall it was an excellent conference with a great group of attendees. The numerous inter-session conversations I had with fellow attendees were as enlightening as the...]]></description>
			<content:encoded><![CDATA[<p>After weeks of keen anticipation, not to mention many long nights of preparation for my own session, <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5zcGFjb25mZXJlbmNlLm9yZy9zcGEyMDExL2luZGV4LnBocA==">SPA 2011</a> has now been and gone.</p>
<p>Overall it was an excellent conference with a great group of attendees. The numerous inter-session conversations I had with fellow attendees were as enlightening as the sessions themselves.</p>
<p>Here are my thoughts about the sessions that I attended.</p>
<h2>Monday 13th June</h2>
<h3>HTML5 Boot Camp</h3>
<p><a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5zcGFjb25mZXJlbmNlLm9yZy9zcGEyMDExL3Nlc3Npb25zL3Nlc3Npb24zOTIuaHRtbA==">This session</a> by Laurie Young and Ismael Celis was one of several focussing on the hot topics of the moment, HTML5 and JavaScript. After a <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5zbGlkZXNoYXJlLm5ldC93aWxkZmFsY29uL2h0bWwtNS1ib290LWNhbXA=">brief introduction to HTML5</a> and what it provides we got cracking with the exercises.</p>
<p>Working in small groups we were asked to implement a web page that allowed the user to drag an image from the file system into it. The next task was to upgrade it to get the image(s) to persist when the user refreshes the page using local storage. Finally we were asked to use a web socket to send the image to a pre built server which would then distribute it to everyone else viewing the same web page.</p>
<p>There was a reasonably large range of JavaScript experience within the session, however I think most people managed to complete the exercises. It provided a great introduction to several of the most universally helpful HTML5 JavaScript APIs.</p>
<h3>Improving Trust in Teams</h3>
<p><a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cuY2FwbGluLmNvbS93cC1jb250ZW50L3VwbG9hZHMvdHJ1c3QtaW4tdGVhbXMtZm9yY2UtZmllbGQuanBn"><img class="alignright size-medium wp-image-6797" title="trust-in-teams-force-field" src="http://blog.caplin.com/wp-content/uploads/trust-in-teams-force-field-300x263.jpg" alt="" width="300" height="263" /></a></p>
<p><a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5zcGFjb25mZXJlbmNlLm9yZy9zcGEyMDExL3Nlc3Npb25zL3Nlc3Npb24zODcuaHRtbA==">Rachel Davies&#8217; session</a> looked at how to <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5hZ2lsZXhwLmNvbS9wcmVzZW50YXRpb25zL1NQQS1JbXByb3ZpbmdUcnVzdEluVGVhbXMucGRm">improve trust in teams</a>.</p>
<p>Split into groups of four we were encouraged to discuss our various experiences of both low and high trust scenarios. Perhaps unsurprisingly most of the scenarios that were highlighted involved low trust. Once each of us had relayed our own trust stories within our groups we were invited to share the most interesting ones with the wider audience.</p>
<p>Afterwards we resumed working in our groups to draw <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy52YWx1ZWJhc2VkbWFuYWdlbWVudC5uZXQvbWV0aG9kc19sZXdpbl9mb3JjZV9maWVsZF9hbmFseXNpcy5odG1s">force field charts</a> that highlight things that we believed help to improve trust and those things that hinder it. We drew these up on a flip charts and again shared our thoughts with everyone attending the session.</p>
<p>Finally we looked at one of the forces behind improving trust and what we might do to nurture it.</p>
<p>It was an enjoyable session that has really made me start to realise that there are perhaps more facets to trust than I had previously considered.</p>
<h3>At the Extremities of Extreme</h3>
<p>This <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5zcGFjb25mZXJlbmNlLm9yZy9zcGEyMDExL3Nlc3Npb25zL3Nlc3Npb24zOTUuaHRtbA==">catchily titled session</a> by Julian Fitzell and Jason Ayers was a fascinating introduction to the theory behind <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5jaW5jb21zbWFsbHRhbGsuY29tL21haW4vMjAxMC8xMC93b2xmX3BhY2tfcHJvZ3JhbW1pbmcv">wolf pack programming</a>. This technique takes the familiar <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5leHRyZW1lcHJvZ3JhbW1pbmcub3JnL3J1bGVzL3BhaXIuaHRtbA==">pair programming</a>, but turns it up a notch, taking collaboration to a new extreme.</p>
<p>I can barely do the concept justice here, but my simple interpretation is that with adequate tool support developers can collaborate without having to be sat around the same PC if they work on precisely the same instance of the code. The tools would allow a developer to see which functions/methods the other people working on the code base were looking at or editing. This allows pair programming to be followed where appropriate, but the navigator can slip off to do some driving if they think of something that will help to remove a block that they have observed that the driver is about to encounter. They also advocated judicial use of spikes to hunt out the quickest solution to a problem.</p>
<p>They had run an <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5zcGFjb25mZXJlbmNlLm9yZy9zcGEyMDExL3Nlc3Npb25zL3Nlc3Npb24zOTAuaHRtbA==">actual wolf pack programming session</a> on Sunday which I am now disappointed that I missed.</p>
<p>At the moment the example sessions they have been running use Smalltalk, however my thoughts are about how we might trial these techniques for JavaScript development.</p>
<h3>Invited Rant</h3>
<p>John Nolan entertained the conference audience with a rant against the term &#8220;software engineering&#8221;, specifically that:</p>
<blockquote><p>Software engineering does not and should not exist</p></blockquote>
<p>He reaffirmed <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5zcGFjb25mZXJlbmNlLm9yZy9vdDk5L3Byb2dyYW1tZS9CZWNrX0tlbnQuaHRt">Kent Beck&#8217;s statement</a> that:</p>
<blockquote><p>Software is software</p></blockquote>
<p>He conceded that:</p>
<blockquote><p>Software is like engineering</p></blockquote>
<p>But saying it is engineering is wrong. Instead he introduced us to a different metaphor:</p>
<blockquote><p>Software is cooking</p></blockquote>
<p>The examples he provided were very compelling, although even John conceded that he wouldn&#8217;t be changing his business card to read Software Chef just yet.</p>
<h2>Tuesday 14th June</h2>
<p>Unfortunately I missed most of Tuesday&#8217;s event as I was preparing for my presentation the following day, which leads me to&#8230;</p>
<h2>Wednesday 15th June</h2>
<h3>Web Apps That Shine</h3>
<p><a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cuY2FwbGluLmNvbS93cC1jb250ZW50L3VwbG9hZHMvd2ViLWFwcHMtdGhhdC1zaGluZTEuanBn"><img class="alignright size-medium wp-image-6810" title="web-apps-that-shine" src="http://blog.caplin.com/wp-content/uploads/web-apps-that-shine1-300x203.jpg" alt="" width="300" height="203" /></a></p>
<p>I co-presented this <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5zcGFjb25mZXJlbmNlLm9yZy9zcGEyMDExL3Nlc3Npb25zL3Nlc3Npb24zOTMuaHRtbA==">HTML5 focussed session</a> with my colleague Adam Iley. The specific context for it was the features of HTML5 that allow up to build web apps.</p>
<p>We introduced the offline support that is provided by HTML5, including <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Rldi53My5vcmcvaHRtbDUvd2Vic3RvcmFnZS8=">local storage</a> and the <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy53My5vcmcvVFIvaHRtbDUvb2ZmbGluZS5odG1s">application cache</a>. Afterwards the attendees paired off and worked at upgrading a <strong>n0tr</strong>, simple note taking website, to work offline.</p>
<p>The second section highlighted the tighter integration we can now get between a web app and the device it is running on. On mobile devices access to <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Rldi53My5vcmcvZ2VvL2FwaS9zcGVjLXNvdXJjZS5odG1s">geolocation</a>, and the <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Rldi53My5vcmcvZ2VvL2FwaS9zcGVjLXNvdXJjZS1vcmllbnRhdGlvbi5odG1s">device orientation</a> is available, whilst on the desktop we can implement <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Rldi53My5vcmcvaHRtbDUvc3BlYy1hdXRob3Itdmlldy9kbmQuaHRtbA==">drag and drop</a> both within the web app as well as to and from other applications, including dropping files into the page. Again we asked the pairs to upgrade the n0tr app to use some of these techniques.</p>
<p>We concluded by talking about portability and other concerns for building and releasing web apps. The <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3dlYmFwcHN0aGF0c2hpbmUuY29tL3ByZXNlbnRhdGlvbi8=">presentation is available online</a> as are the <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3dlYmFwcHN0aGF0c2hpbmUuY29tL24wdHIuemlw">exercises</a> that we ran.</p>
<h3>Invited Rant</h3>
<p>Jason Gorman&#8217;s rant was titled <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2NvZGVtYW5zaGlwLmNvLnVrL3BhcmxlenVtbC9ibG9nLz9wb3N0aWQ9MTA0MQ==">Slow and Dirty</a>.</p>
<p>It was a thought provoking view on our responsibilities as developers with plenty of statistics to help back up his points. When starting on a new project the features come in thick and fast, however over time productivity starts to plateau. On the 8th major release of a major product (no names mentioned) the cost to write or change a line of code was 20 times as much as it had been initially.</p>
<p>Making our software maintainable is our responsibility, and is not something that we should abandon in our quest to keep adding new features to keep our customers happy. We need to be prepared to pace ourselves for a marathon, not a sprint.</p>
<p>Finally, beware the statistical aberrations that seem to have flouted all of this advice and are major successes nevertheless. Just because your great aunt smoked 60 cigarettes a day and lived to be 103 doesn&#8217;t mean that to give yourself the best chance to survive to 103 means that you should smoke 60 a day.</p>
<h3>Specification By Example: By Example</h3>
<p><a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cuY2FwbGluLmNvbS93cC1jb250ZW50L3VwbG9hZHMvc3BlY2lmaWNhdGlvbi1ieS1leGFtcGxlLmpwZw=="><img class="alignright size-medium wp-image-6796" title="specification-by-example" src="http://blog.caplin.com/wp-content/uploads/specification-by-example-274x300.jpg" alt="" width="274" height="300" /></a></p>
<p>The <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5zcGFjb25mZXJlbmNlLm9yZy9zcGEyMDExL3Nlc3Npb25zL3Nlc3Npb24zNTkuaHRtbA==">final session I attended</a> was run by Lasse Koskela. Lasse asked us to split up into groups of three, then handed out an index card to each group that specified a requirement for a particular software system. Within our groups we needed to capture the specification by writing or drawing out the various  examples we could think of.</p>
<p>My group was asked to produce the specification for an email verification system. We sketched out the interaction between the server and the user, defining 5 different scenarios that we could think of, one of which covered a hacker.</p>
<p>Two members of each group were asked to switch over with people from other groups. The remaining person on each group was asked to explain the examples they had drawn up to the new members, and we were asked what improvements could be made.</p>
<p>Finally everyone changed groups again, moving onto a requirement that none of us had worked on before. We are asked to review what had already been done, then start afresh and come up with our own examples.</p>
<p>Overall the session went very well and it was interesting to see how much would be achieved in a very short period of time by sketching out the examples with tight collaboration between all the members of the group. There was a warning flag though that the lifespan of the examples that we created was limited as there was contextual information that was only available to those who were involved in the conversations surrounding the creation of the examples &#8211; a little more structure might be necessary if these are to persist over a long period of time. Nevertheless this was a technique that I&#8217;ll be trying out at some point soon.</p>
 <img src="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=6747" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.caplin.com/2011/06/17/what-i-learnt-at-spa-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows 8 with HTML5/JavaScript apps</title>
		<link>http://blog.caplin.com/2011/06/02/windows-8-with-html5javascript-apps/</link>
		<comments>http://blog.caplin.com/2011/06/02/windows-8-with-html5javascript-apps/#comments</comments>
		<pubDate>Thu, 02 Jun 2011 08:09:07 +0000</pubDate>
		<dc:creator>Martin Tyler</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://blog.caplin.com/?p=6586</guid>
		<description><![CDATA[Microsoft have previewed Windows 8 at the D9 conference, including a video showing it off. It seems like a slightly crazy mix of backwards compatibility and some quite cool new ideas that are meant to be suitable for keyboard/mouse based systems as well as touch based. What is interesting though...]]></description>
			<content:encoded><![CDATA[<p>Microsoft have previewed Windows 8 at the D9 conference, including a video showing it off.</p>
<p><iframe width="560" height="349" src="http://www.youtube.com/embed/p92QfWOw88I" frameborder="0" allowfullscreen></iframe></p>
<p>It seems like a slightly crazy mix of backwards compatibility and some quite cool new ideas that are meant to be suitable for keyboard/mouse based systems as well as touch based. What is interesting though is the mention that the new style tiles and apps are built on a new platform using HTML5 and JavaScript. It seems unclear what the future of Silverlight is, but what is clear is that Microsoft is definitely embracing the HTML5 world.</p>
<p>This can only be good for HTML5 development and tools.</p>
 <img src="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=6586" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.caplin.com/2011/06/02/windows-8-with-html5javascript-apps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 Toolkits for Complex Web Applications</title>
		<link>http://blog.caplin.com/2010/12/01/html5-toolkits-for-complex-web-applications/</link>
		<comments>http://blog.caplin.com/2010/12/01/html5-toolkits-for-complex-web-applications/#comments</comments>
		<pubDate>Wed, 01 Dec 2010 14:52:48 +0000</pubDate>
		<dc:creator>Andrew MacLeod</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Software Architecture]]></category>
		<category><![CDATA[UX]]></category>
		<category><![CDATA[Caplin Trader]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[User Experience]]></category>

		<guid isPermaLink="false">http://blog.caplin.com/?p=4417</guid>
		<description><![CDATA[Embarking on developing a web application can be bewildering: there's no shortage of JavaScript toolkits of all different shapes and sizes but there's no guiding light.  This article attempts to navigate through the maze of toolkits to assist making technology choices when building a web application.]]></description>
			<content:encoded><![CDATA[<p>At Caplin, we build very complex web applications for financial trading, and we are often asked for advice about which of the many JavaScript toolkits out there are the best.</p>
<p>Embarking on developing a web application can be bewildering: there&#8217;s no shortage of JavaScript toolkits of all different shapes and sizes but there&#8217;s no guiding light.  Microsoft and Adobe, by contrast, offer a much greater degree of comfort with their methodologies, libraries and tool support &#8211; but only if you are willing to restrict your application to running on their respective platforms.</p>
<p>There are some great JavaScript tools out there, however, and this article attempts to navigate through the maze of toolkits to assist making technology choices when building a web application.</p>
<p><strong>User Experience is Paramount</strong></p>
<p>The GUI is the most prominent part of the application, and is usually the most expensive to develop.  An important part of the UX rests on your choice of widgets and how customisable they are.  You should choose widgets that will give you the best possible starting point; if you can&#8217;t find what you want, you will have to consider composing your own.</p>
<p><span id="more-4417"></span></p>
<p>Most widget toolkits are general purpose, but more sophisticated widgets are emerging.  <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Rldi5leHRqcy5jb20vZGVwbG95L2Rldi9leGFtcGxlcy8=">ExtJS</a>, <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2pxdWVyeXVpLmNvbS9kZW1vcy8=">jQuery</a> and <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2RlbW9zLmRvam90b29sa2l0Lm9yZy9kZW1vcy8=">Dojo</a> provide widgets ranging from grids to email suites.  Caplin specifically targets widgets for financial sector clients that are oriented to financial domain specific objects and delivering real-time prices to the screen.</p>
<p>Widgets are typically customised using templates, configuration and programatically.  Templating is by far the quickest approach, and this has been well proven with Silverlight’s XAML.  HTML also works very well as a view templating language, and HTML5’s data attributes can be used to further this approach.  Caplin has developed some easy-to-use frameworks that use HTML/CSS templating to build new widgets quickly.</p>
<p>UX does not stop at widget selection though: how they interact is also crucial.  User workflow across all the widgets in the application needs to be implemented with due respect to the overall application structure.</p>
<p><strong>Structural Patterns</strong></p>
<p>Most GUIs conform to some kind of structural pattern.   <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL21hcnRpbmZvd2xlci5jb20vZWFhRGV2L1Bhc3NpdmVTY3JlZW4uaHRtbA==">Passive View</a>, <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9QcmVzZW50ZXJfRmlyc3Q=">Presenter First</a> and <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL21hcnRpbmZvd2xlci5jb20vZWFhRGV2L1ByZXNlbnRhdGlvbk1vZGVsLmh0bWw=">Presentation Model</a> (aka MVVM) are all good design approaches.  There&#8217;s little merit in debating which precise pattern is &#8220;best&#8221; – if it were that simple then Martin Fowler would have told us the answer by now.  The most important thing is that you should be able to build your widgets with the appropriate degree of composability, isolation and testability.</p>
<p>All MVC-derivatives leverage the observer pattern, and it&#8217;s crucial to choose an implementation to support the right level of decoupling (such as pub/sub).  For example, a web application typically comprises a layout manager which houses its widgets and manages screen real estate, and you will need to consider how your component-level widgets will communicate with application-level code.</p>
<p>You may decide to use additional utilities to implement structural patterns in your application, but you need to proceed with caution.</p>
<p><strong>Toolkit Selection</strong></p>
<p>JavaScript toolkits come in two categories: widgets and utilities.  Utilities such as <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5wcm90b3R5cGVqcy5vcmcv">prototype.js</a> and <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2RvY3VtZW50Y2xvdWQuZ2l0aHViLmNvbS9iYWNrYm9uZS8=">backbone.js</a> can serve as the basis for building your own widgets, but that starting point doesn’t suit everyone.</p>
<p>The lack of JavaScript standards means that, invariably, widget toolkits come with their own JavaScript extensions that are both integral to the widgets themselves and also feature in the API.  Combining widgets from more than one toolkit requires special care, and each toolkit brings its own idiosyncratic syntax.  For example, jQuery has its own $() selector syntax, and underscore.js which (as suggested by its name) entirely revolves around the &#8216;_&#8217; symbol.  This can be quite distracting when trying to standardise development across an enterprise.</p>
<p>For each toolkit you adopt, ensure that the benefits outweigh the incremental burden that you are taking on, and ensure that you are happy to embrace its idioms and syntax.</p>
<p>At Caplin we’ve made enthusiastic use of toolkits such as ExtJS, jQuery and Emprise charting, but have found it necessary to build our own frameworks for layout management, real-time grids and templating/data-binding.  The last one of these has proved so useful that we are planning to open source this in the near future.</p>
 <img src="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=4417" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.caplin.com/2010/12/01/html5-toolkits-for-complex-web-applications/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Fiddler to help develop cross domain capable JavaScript web applications</title>
		<link>http://blog.caplin.com/2010/03/19/using-fiddler-to-help-develop-cross-domain-capable-javascript-web-applications/</link>
		<comments>http://blog.caplin.com/2010/03/19/using-fiddler-to-help-develop-cross-domain-capable-javascript-web-applications/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 10:50:01 +0000</pubDate>
		<dc:creator>Phil Leggetter</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[fiddler]]></category>

		<guid isPermaLink="false">http://www.leggetter.co.uk/?p=758</guid>
		<description><![CDATA[This post is going to be short and sweet. “Short” because Fiddler makes working around this problem so simple. And “Sweet” because I think this is really powerful and will allow you to develop applications that show why cross domain access, in some situations, should be allowed. In my last...]]></description>
			<content:encoded><![CDATA[This post is going to be short and sweet. “Short” because <a href="http://www.fiddler2.com/fiddler2/">Fiddler</a> makes working around this problem so simple. And “Sweet” because I think this is really powerful and will allow you to develop applications that show why cross domain access, in some situations, should be allowed.

In my last post on <a href="http://www.leggetter.co.uk/2010/03/12/making-cross-domain-javascript-requests-using-xmlhttprequest-or-xdomainrequest.html">Making cross domain JavaScript requests using XMLHttpRequest or XDomainRequest</a> I demonstrated that in order to access a resource (web page/web service) the server needs to respond to your application/JavaScript HTTP requests with an HTTP header of <a href="http://www.w3.org/TR/2008/WD-access-control-20080912/#access-control-allow-origin">“Access-Control-Allow-Origin”</a>. The problem arises when you are trying to access a resource that doesn’t presently send the required HTTP header, but you really need it to (I’ve addressed a similar problem to this when developing Silverlight applications and the solution, again, was to use <a href="http://www.leggetter.co.uk/2009/10/30/using-fiddler-to-trick-silverlight-into-allowing-a-crossdomain-web-request.html">Fiddler to trick Silverlight into allowing a crossdomain Web Request</a>). For development purposes you’ll need to add the required header to the server HTTP response in your development environment. This is really simple using Fiddler.
<span id="more-758"> </span>
All you need to do is add a new custom rule. You can do this via the menu option: <strong>Rules -&gt; Customize Rules…</strong>
<div id="attachment_759" class="wp-caption alignnone" style="width: 409px;">

<a class="thickbox no_icon" title="Customize Rules" rel="gallery-758" href="http://www.leggetter.co.uk/wp-content/uploads/2010/03/CustomizeRules.png"><img class="size-full wp-image-759" title="Customize Rules" src="http://www.leggetter.co.uk/wp-content/uploads/2010/03/CustomizeRules.png" alt="" width="399" height="289" /></a>
<p class="wp-caption-text">Fiddler Customize Rules option</p>

</div>
This will bring up a JScript.NET file (if you don’t like the thought of JScript you can just pretend it’s JavaScript) called <em>CustomRules.js</em>. In that file you will see a number of functions/methods that are called at certain points during an HTTP request or response. The method we are interested in is called <code>OnBeforeResponse</code> and what we want to do is to add the <em>Access-Control-Allow-Origin</em> header to trick the browser/scripting engine into thinking that the resource we are requesting allows the cross domain request.
<pre class="brush: jscript;">static function OnBeforeResponse(oSession: Session)
{
	oSession.oResponse.headers.Add("Access-Control-Allow-Origin", "*");
}</pre>
The code above will add this header to all HTTP responses. You can of course add an <code>if</code> statement so that the header is only added when a particular condition is matched, such as a responses from <a href="http://www.leggetter.co.uk">http://www.leggetter.co.uk</a>.
<pre class="brush: jscript;">static function OnBeforeResponse(oSession: Session)
{
	if (oSession.HostNameIs("www.leggetter.co.uk"))
	{
		oSession.oResponse.headers.Add("Access-Control-Allow-Origin", "*");
	}
}</pre>
<small>The code snippet above has not been tested</small>

Once you have added your code to the <code>OnBeforeResponse</code> method you can save and close the CustomRules.js file. Fiddler will detect that this file has been modified and compile it in the background so that it can use the new code with each request and response that it processes.

The next time that Fiddler is processing an HTTP response it will call this method, your code will run, and the <em>Access-Control-Allow-Origin</em> HTTP header added to the response.
<pre class="brush: plain;">HTTP/1.1 200 OK
Connection: close
Date: Fri, 19 Mar 2010 11:04:51 GMT
Server: Microsoft-IIS/6.0
Content-Type: text/html; charset=utf-8
Expires: Fri, 19 Mar 2010 11:03:51 GMT
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *</pre>
For more information on custom rules and generally developing using Fidder see their <a href="http://www.fiddler2.com/Fiddler/dev/">Developer Info section</a>.]]></content:encoded>
			<wfw:commentRss>http://blog.caplin.com/2010/03/19/using-fiddler-to-help-develop-cross-domain-capable-javascript-web-applications/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The banking exodus from IE6 begins?</title>
		<link>http://blog.caplin.com/2010/03/02/the-banking-exodus-from-ie6-begins/</link>
		<comments>http://blog.caplin.com/2010/03/02/the-banking-exodus-from-ie6-begins/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 17:22:12 +0000</pubDate>
		<dc:creator>Patrick Myles</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Trading Technology]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[IE6]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://blog.caplin.com/?p=1543</guid>
		<description><![CDATA[We&#8217;ve all seen the retail and consumer space push to ditch IE6 gathering pace over the last 6 months, including a petition to the UK government and Google&#8217;s announcement that their online productivity suite stopped supporting IE6 yesterday. But the corporates (and specifically banking)  have been a lot more reluctant...]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve all seen the retail and consumer space push to ditch IE6 gathering pace over the last 6 months, including a <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL25ld3MuYmJjLmNvLnVrLzEvaGkvdGVjaG5vbG9neS84NDkyODYyLnN0bQ==" 0="target="_blank"">petition to the UK government</a> and Google&#8217;s announcement that their online productivity suite <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL25ld3MuY25ldC5jb20vODMwMS0zMDY4NF8zLTEwNDQ0NTc0LTI2NS5odG1s" 0="target="_blank"">stopped supporting IE6 yesterday</a>. But the corporates (and specifically banking)  have been a lot more reluctant to follow suit. But is this about to change?</p>
<p>Rumour on the street has it that, finally, the investment banks are going to start abandoning IE6. Barclays are allegedly going to do an enterprise-wide rollout of IE8 in Q2 of this year (put back from Q3 last year). Even more surprising (and impressive) is a rumour that Standard Bank of South Africa are going to ditch Microsoft browsers completely and move to Chrome for their corporate standard!</p>
 <img src="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1543" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.caplin.com/2010/03/02/the-banking-exodus-from-ie6-begins/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JavaScript Variable Naming Convention</title>
		<link>http://blog.caplin.com/2010/02/10/javascript-variable-naming-convention/</link>
		<comments>http://blog.caplin.com/2010/02/10/javascript-variable-naming-convention/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 16:05:50 +0000</pubDate>
		<dc:creator>Ian Alderson</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://blog.caplin.com/?p=1098</guid>
		<description><![CDATA[When I joined Caplin 10 years ago I came from a company that used Hungarian notation to name its C++ and Visual Basic variables. For me, it seemed a natural progression to continue to use these naming conventions and adapt them to be suitable for the JavaScript code that I...]]></description>
			<content:encoded><![CDATA[<p>When I joined Caplin 10 years ago I came from a company that used <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9IdW5nYXJpYW5fbm90YXRpb24=">Hungarian notation</a> to name its C++ and Visual Basic variables. For me, it seemed a natural progression to continue to use these naming conventions and adapt them to be suitable for the JavaScript code that I now writing.</p>
<p>The evolution of software practices ebbs and flows over time, and it seems that Hungarian notation is currently out of favour. This is especially apparent with some of the new developers that have joined the team here at Caplin. One of the first questions they ask is often about the naming convention that we use.</p>
<p><span id="more-1098"></span></p>
<p><strong>Hungarian Notation is useful in JavaScript</strong></p>
<p>I believe that an untyped language like JavaScript benefits greatly from Hungarian notation, allowing the intended type of a variable to be determined from its name. If I am debugging some code that is going wrong I can quickly check that the data associated with that variable is of the expected type. Also if I am writing new code I know which methods I can invoke on the variable.</p>
<p>The scoping within JavaScript is strange too. If a developer forgets to add a <code>var</code> declaration for a particular local variable within a function then the variable is added to the global scope, with the potential of nasty unforeseen side effects.</p>
<p><strong>Caplin&#8217;s JavaScript Naming Convention</strong></p>
<p>At Caplin, we have two components that are added to the start of the names of our JavaScript variables: one represents the type, and the other represents the scope.</p>
<p><strong>Type Prefix</strong></p>
<ul>
<li><code>b</code> &#8211; a Boolean variable. We only expect it to have a value <code>true</code> or <code>false</code>. For example <code>bIsVisible</code>.</li>
<li><code>e</code> &#8211; a DOM element. Provided its not <code>null</code> we expect to be able to access <code>childNodes</code> and so on. For example <code>eGridBody</code>.</li>
<li><code>f</code> &#8211; a function pointer. Typically this will be invoked at some stage in the future. For example <code>fCallback</code>.</li>
<li><code>m</code> &#8211; a map. For example <code>mPropertyNamesToValues</code>.</li>
<li><code>n</code> &#8211; number, either a integer or a float. For example <code>nColumnIndex</code>.</li>
<li><code>o</code> &#8211; an object. We don&#8217;t try to differentiate between all the different object types we have defined within our code with dozens of different prefixes, this would get too complicated to remember. Typically we use <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2pzZG9jLnNvdXJjZWZvcmdlLm5ldC8=">JsDoc</a> to identify the types, if the scope of a variable is not small enough to see its type. For example <code>oObservable</code>.</li>
<li><code>p</code> &#8211; an array. This should really use an <code>a</code> prefix, however this is a throw back to the original Hungarian notation from my C++ days where an array was just a pointer. For example <code>pQueue</code>.</li>
<li><code>s</code> &#8211; a string. Provided its not <code>null</code> we expect to be able to invoke methods like <code>match()</code>. For example <code>sUsername</code>.</li>
<li><code>v</code> &#8211; a variant, where various different types might be allowed. A typical example of where this might be used is a generic debugging method that is happy to take any type of argument and output it to a log. For example <code>vValueToLog</code>.</li>
</ul>
<p><strong>Scope Prefix</strong></p>
<ul>
<li><code>m_</code> &#8211; private member variable. Although there are techniques to hide member variables there are performance costs associated with them. The <code>m_</code> prefix is a gentle reminder that only the class the member variable is defined in should be accessing it. In fact, when the code is obfuscated these private members may also be obfuscated since they aren&#8217;t part of of the public interface of the class. For example <code>this.m_sSubject</code>.</li>
<li><code>g_</code> &#8211; global variable. These are <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2MyLmNvbS9jZ2kvd2lraT9HbG9iYWxWYXJpYWJsZXNBcmVCYWQ=">used sparingly</a>. If a variable has a value to assigned to it within a method but does not have a g_ prefix then beware, this is probably a mistake and we now have an unexpected side effect. For example <code>g_bIsDevelopment</code>.</li>
<li>All other variables, such as local variables or function arguments, have no scope prefix.</li>
</ul>
<p><strong>Horses for Courses</strong></p>
<p>To be honest, although I use Hungarian notation throughout all of my JavaScript code, I avoid it altogether when coding in other languages such as Java. The reason for this is simply that Java is a typed language, and I don&#8217;t feel that this adds any benefit, however <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9Kb2VsX1Nwb2xza3k=">Joel Spolsky</a> makes a great case for using it, even in the case of a typed language, in his blog <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5qb2Vsb25zb2Z0d2FyZS5jb20vYXJ0aWNsZXMvV3JvbmcuaHRtbA==">Making Wrong Code Look Wrong</a>.</p>
 <img src="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1098" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.caplin.com/2010/02/10/javascript-variable-naming-convention/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pitfalls of Exception expectations in JsUnit</title>
		<link>http://blog.caplin.com/2010/01/29/pitfalls-of-exception-expectations-in-jsunit/</link>
		<comments>http://blog.caplin.com/2010/01/29/pitfalls-of-exception-expectations-in-jsunit/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 12:00:25 +0000</pubDate>
		<dc:creator>Ian Alderson</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JsCoverage]]></category>
		<category><![CDATA[Mock4JS]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[Test Driven Development]]></category>
		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://blog.caplin.com/?p=1084</guid>
		<description><![CDATA[At Caplin we use the JsUnit framework to test our JavaScript code. Over time we have made minor modifications to it, integrating Mock4JS and JSCoverage, as well as adding a few of our own extensions that are sympathetic to our JavaScript coding style, however, by and large, our tests are...]]></description>
			<content:encoded><![CDATA[<p>At Caplin we use the <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5qc3VuaXQubmV0Lw==">JsUnit</a> framework to test our JavaScript code. Over time we have made minor modifications to it, integrating <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL21vY2s0anMuc291cmNlZm9yZ2UubmV0Lw==">Mock4JS</a> and <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3NpbGljb25mb3Jrcy5jb20vanNjb3ZlcmFnZS8=">JSCoverage</a>, as well as adding a few of our own extensions that are sympathetic to our JavaScript coding style, however, by and large, our tests are written using plain old JsUnit assertions.</p>
<p>One of the main reasons we were keen to adopt JsUnit five years ago was its similarity to <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5qdW5pdC5vcmcv">JUnit 3</a>. Back then our developers had been using JUnit for a few years, and familiarity of the JsUnit API meant that we could immediately start writing tests. Unfortunately the old adage &#8220;familiarity breeds contempt&#8221; reared its ugly head, and we discovered that our main issue with JsUnit were the occasional, very subtle, differences between it and JUnit. The logic for a test that works in JUnit might not work in JsUnit.<br />
<span id="more-1084"></span><br />
An example of this is highlighted by the test that would be written for the example <code>JobQueue</code> class defined below. Its purpose is to queue JavaScript functions for invocation at some point in the future. The <code>addJob()</code> method employs the <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9GYWlsLWZhc3Q=">fast-fail</a> philosophy to throw an exception if the <code>fJobToExecuteLater</code> argument is <code>null</code> or <code>undefined</code>, rather than fail later on when an attempt is made to execute it.</p>
<pre class="brush: jscript; title: ; notranslate">
function JobQueue()
{
   this.m_pQueue = [];
}

JobQueue.prototype.addJob = function(fJobToExecuteLater)
{
   if (fJobToExecuteLater == null) // this is true if it is undefined
   {
      throw new Error(&quot;JobQueue.addJob: Job cannot be null or undefined&quot;);
   }
   this.m_pQueue.push(fJobToExecuteLater);
};

// other methods...
</pre>
<p>The JsUnit test written to verify the behaviour would look something like:</p>
<pre class="brush: jscript; title: ; notranslate">
var g_oJobQueue = null;

function setUp()
{
   g_oJobQueue= new JobQueue();
}

function testAddJobThrowsExceptionIfJobToExecuteLaterIsNull()
{
   try
   {
      g_oJobQueue.addJob(null);
      fail(&quot;Unexpected success invoking addJob() with null job&quot;);
   }
   catch (e)
   {
      // expected exception
   }
}
</pre>
<p>Casting a casual (JUnit 3) glance over this test, everything looks to be in order. The test checks that an exception is thrown if the <code>addJob()</code> method is passed a <code>null</code> argument and remembers to invoke <code>fail()</code> if the exception isn&#8217;t thrown. This latter point is important since if it is omitted then the test will pass regardless of whether an exception is thrown or not.</p>
<p>The equivalent test in Java would work without any problems, however in JavaScript there is a hidden bug within this test logic. Within JUnit the <code>fail()</code> method throws a subclass of <code>Error</code>, which <strong>won’t</strong> be caught by a catch block expecting an Exception. Unfortunately JavaScript has no such distinctions between errors and exceptions, and the call to <code>fail()</code> throws an exception which <strong>will</strong> be caught within the catch block.</p>
<p><strong>Solutions to the Exception expection issue</strong></p>
<p>There are two approaches that we have taken to resolving this issue.</p>
<p><strong>1.</strong> We extended the JsUnit API to add a new assertion method, <code>assertFails()</code>, that encapsulates the logic necessary to ensure that an exception is thrown, and fail if it hasn&#8217;t. It takes three arguments:</p>
<p><strong>i.</strong> A comment to output if the test fails<br />
<strong>ii.</strong> A reference to the function to invoke which is expected to throw an exception, if this doesn&#8217;t throw an exception then the assertion fails<br />
<strong>iii.</strong> The exception that is expected to be thrown (optional, if omitted the assertion just ensures that an exception is thrown)</p>
<p>Using the <code>addJob()</code> test can be rewritten to use <code>assertFails()</code>:</p>
<pre class="brush: jscript; title: ; notranslate">
function testAddJobThrowsExceptionIfJobToExecuteLaterIsNull()
{
   assertFails(&quot;Unexpected success invoking addJob() with null job&quot;,
                   function() {
                      g_oJobQueue.addJob(null);
                   });
}
</pre>
<p><strong>2.</strong> We verify that the exception that is thrown is the one that we expect. This particular approach has been met with trepidation from some of our developers who are concerned that verification of exceptions will lead to fragile test code, prone to break if someone changes the text within an exception (presumably to make it more helpful). There are certainly pros and cons to this, however in my experience it is rare that changes are made to the descriptions passed into the exceptions thrown by our code, and the overhead of these verifications is negligible.</p>
<p>The original test code can be rewritten to assert that the exception is the expected one:</p>
<pre class="brush: jscript; title: ; notranslate">
function testAddJobThrowsExceptionIfJobToExecuteLaterIsNull()
{
   try
   {
      g_oJobQueue.addJob(null);
      fail(&quot;Unexpected success invoking addJob() with null job&quot;);
   }
   catch (e)
   {
      var oExpectedException =
               new Error(&quot;JobQueue.addJob: Job cannot be null or undefined&quot;);
      assertEquals(oExpectedException.toString(), e.toString());
   }
}
</pre>
<p>Alternatively <code>assertFails()</code> can be used as such:</p>
<pre class="brush: jscript; title: ; notranslate">
function testAddJobThrowsExceptionIfJobToExecuteLaterIsNull()
{
   assertFails(&quot;Unexpected success invoking addJob() with null job&quot;,
                   function() {
                      g_oJobQueue.addJob(null);
                   },
                   new Error(&quot;JobQueue.addJob: Job cannot be null or undefined&quot;));
}
</pre>
<p><strong>Conclusion</strong></p>
<p>This article is not intended to be a criticism of JsUnit. The issue highlighted here is simply due to a difference between the JavaScript and Java languages with respect to their exception handling which led to some tests being marked as successful when they shouldn&#8217;t. Over the last five years I have found that JsUnit has been reliable unit testing framework and, combined with Mock4JS and a TDD philosophy, it can form the solid foundations from which enterprise level JavaScript APIs and applications can be built.</p>
<p>Since we made our decision to use JsUnit we have never really looked back. So far it has managed to do everything that we have needed from it. However if you are looking into unit testing your JavaScript, then <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9MaXN0X29mX3VuaXRfdGVzdGluZ19mcmFtZXdvcmtzI0phdmFTY3JpcHQ=">this list of JavaScript unit testing frameworks</a> should be a good starting point to uncover one that is suitable for you. Just remember, it doesn&#8217;t matter which framework you choose, you need to be aware of the subtle nuisances of JavaScript, compared to any other languages you might be familiar with, to avoid the sort of trap that we fell into.</p>
 <img src="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1084" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.caplin.com/2010/01/29/pitfalls-of-exception-expectations-in-jsunit/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

