<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Azzamallow</title>
	<atom:link href="http://azzamallow.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://azzamallow.wordpress.com</link>
	<description>a better slogan is on its way</description>
	<lastBuildDate>Mon, 28 Jun 2010 11:25:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='azzamallow.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Azzamallow</title>
		<link>http://azzamallow.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://azzamallow.wordpress.com/osd.xml" title="Azzamallow" />
	<atom:link rel='hub' href='http://azzamallow.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Five reasons to avoid mocking jQuery</title>
		<link>http://azzamallow.wordpress.com/2010/06/28/five-reasons-to-avoid-mocking-jquery/</link>
		<comments>http://azzamallow.wordpress.com/2010/06/28/five-reasons-to-avoid-mocking-jquery/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 11:09:47 +0000</pubDate>
		<dc:creator>azzamallow</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[mimicJS]]></category>
		<category><![CDATA[mocking]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://azzamallow.wordpress.com/?p=95</guid>
		<description><![CDATA[Mocking is something developers use quite regularly when unit testing their code base (duh). Developers love the fact that they can isolate a unit of code from other units and often use mocks to enforce that. I personally think there is too much mocking going on! I also think there are too many unit tests out [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azzamallow.wordpress.com&amp;blog=14211211&amp;post=95&amp;subd=azzamallow&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Mock_object" target="_blank">Mocking</a> is something developers use quite regularly when unit testing their code base (duh). Developers love the fact that they can isolate a unit of code from other units and often use mocks to enforce that. I personally think there is too much mocking going on! I also think there are too many unit tests out there and not enough integration tests, which I&#8217;ve chosen to define as the following (Java hat is on).</p>
<h3>Integration tests</h3>
<p>Put simply, tests which stretches over two or more tiers in the application. Tiers may be modules in the code base or a database or search engine. There are no mocks involved in this approach but stubbing if necessary. I wont write anything you don&#8217;t already know, so I&#8217;ll leave it there.</p>
<h3>Unit tests</h3>
<ol>
<li>As is widely accepted, tests a single unit (class if you will) entirely. This may require the developer to mock out any dependencies (passed either through the constructor (yay) or hacked by making protected methods in your implementation (yuk)). The number of dependencies on the class usually influence the number of mocks in the unit test,</li>
<li>Integration amongst a few classes that are tightly coupled together. Sometimes there is one entry point into a class which depends on a few more classes. For example, there may be a simple feature which depends on a bunch of XML processing, some transformations and eventually spits out some nice object for you to use. Sure the bits and pieces which make the whole thing work are unit tested in the traditional sense, but the class that provides the entry point should be? I think it should be tested more like an integration test, with each test hitting multiple classes. Its not quite good enough to be labelled an integration test, so I&#8217;ve made some wiggle room under the unit test umbrella. In my own mind at least :)</li>
</ol>
<p>An important point though&#8230;</p>
<p><strong>If there is too many dependencies or too much mocking, chances are the class isn&#8217;t doing much and just delegates a lot, which means more mocks and more detachment from reality. </strong></p>
<p>Given this statement allow me to make a few points in regards to unit testing your Javascript code! More specifically, unit testing with <a href="http://jquery.com/" target="_blank">jQuery</a>.</p>
<p>jQuery is nice, I really like it. I also like testing my code, however its always a pain in the ass when it comes to testing any kind of Javascript! I&#8217;ve built (well, building) a testing framework for Javascript which attempts to help test your jQuery, called <a href="http://github.com/azzamallow/MimicJS" target="_blank">MimicJS</a>. At this point the jQuery component of the framework needs to be addressed and probably removed, mainly for the reasons I am going to describe here.</p>
<p>If there is one thing I have learnt about Javascript recently it is that mocking jQuery is a bad idea. Those who have done it know the pain, and hopefully they will agree with what I am about to write. Some of you may never have done it before and are going to read all of this and will never mock jQuery. I envy you, you bastard.</p>
<p>Note: the answers (well, my answers) are at the bottom of this post. I decided to list the reasons for not mocking jQuery first, then come up with a solution at the end to bring it all points together.</p>
<h2>Mocking jQuery is hard to do</h2>
<p>Why bother mocking something that is hard to mock?</p>
<p>The way jQuery is written and works is quite extraordinary. Where most of us are used to the traditional class/method patterns, jQuery disregards all of that and instead uses Javascript to its advantage. Rather than bending Javascript to fit, it works with it. I guess you can look at jQuery as a giant Javascript DSL. Have you ever written an extensive builder in Java, say to create your domain objects? If so, have you ever tried mocking the builder out? Of course not! It may or may not make sense to, but I can almost assure you it would be complicated. So complicated in fact you may be enticed to just use the builder and forget about mocking it altogether&#8230;</p>
<p>I&#8217;ll now talk about my own experiences whilst creating MimicJS and working with jQuery. The most complicated part by far was attempting to mimic jQuery (you&#8217;ll have to have a look at the project yourself to know what im talking about. Do you like my marketing tactics?). Testing behaviour in Javascript is actually quite easy. Most developers who are too lazy to find a behaviour testing framework test the behaviour within the spec itself, it only takes a line or two. So developing mimic for more traditional testing was relatively easy. Testing the behaviour of jQuery was down right painful and also unpolished. If I were to keep that part of MimicJS around I would spend a large chunk of my dev time maintaining it. So for that, I will be removing it soon and replacing with something a little sustainable. You&#8217;ll read about it soon.</p>
<h2>Mocking jQuery means fragile specs</h2>
<p>So what if it is hard to mock jQuery? Some propeller-head will spend endless days and nights building a tool good enough. Well, I can tell you it wont be me :) (And im not admitting im any sort of propeller-head, I&#8217;d rather be called a geek). Lets say a tool good enough existed, why wouldn&#8217;t I just use it and be done with it?</p>
<p>I&#8217;m just making up syntax here, but if a tool good enough to test the behaviour of jQuery existed, this is what it would look like (more or less).</p>
<div style="border:1px solid #CCC;font-size:13px;margin:10px;padding:10px;">
<pre>
<span style="color:green;">// Implementation</span>
function display() {
    var html = <span style="color:green;">'&lt;span&gt;I am now displayed, and this is the message.&lt;/span&gt;'</span>;
    var fixedHeight = 200;
    $(<span style="color:green;">'#dialog'</span>).empty().html(html).show().css(<span style="color:green;">'height'</span>, fixedHeight);
}

<span style="color:green;">// Spec</span>
it('should display the dialog with a default message provided', function() {
    display();
    $.usingSelector(<span style="color:green;">'#dialog'</span>).should(<span style="color:green;">'empty'</span>).and().shouldAlso(<span style="color:green;">'show'</span>).and().shouldAlso(<span style="color:green;">'css'</span>, with(<span style="color:green;">'height'</span>, 200));
});
</pre>
</div>
<p>Now im going to change the implementation. lets say I call height() instead of setting the height using css(), my test is going to break.</p>
<div style="border:1px solid #CCC;font-size:13px;margin:10px;padding:10px;">
<pre>
<span style="color:green;">// Implementation</span>
function display() {
    var html = <span style="color:green;">'&lt;span&gt;I am now displayed, and this is the  message.&lt;/span&gt;'</span>;
    var fixedHeight = 200;
    $(<span style="color:green;">'#dialog'</span>).empty().html(html).show().height(fixedHeight);
}
</pre>
</div>
<p>Seriously obvious right? Its a simple change, however it doesn&#8217;t change the behaviour of the what &#8220;really&#8221; happens, only the behaviour of the call. This is a single isolated example, but in a large code base you do not want to be making these little changes. Some may argue against that, saying that the call has changed so the tests should fail. I disagree. Like I said the behaviour of what &#8220;really&#8221; happens has not changed. I&#8217;m not interested in maintaining unit tests to that granularity that give me no real benefit. If what &#8220;really&#8221; happens changes, then and only then should the tests fail. &#8220;really&#8221; &#8220;really&#8221; &#8220;really&#8221;. And don&#8217;t forget about BDD. Unless you have a spec that &#8220;should fail when I change the way the height is set on an element&#8221;, then these specs shouldn&#8217;t fail for trivial reasons.</p>
<p>And what about an upgrade to jQuery? You&#8217;ll upgrade and any serious breakages are going to be mixed in with useless ones, all of which need to be resolved. Wouldn&#8217;t you rather specs fail for good reasons only?</p>
<p>More to the point, if the spec was some kind of integration test it would never fail over small changes like the one shown&#8230;</p>
<h2>Mocking jQuery means zero DOM interactions</h2>
<p>Easily forgotten, mostly because everyone hates it but there is also a <a href="http://en.wikipedia.org/wiki/Document_Object_Model" target="_blank">DOM</a> involved in all of this. In fact most developers who say they hate Javascript actually hate the DOM. Given that, it sounds like a good idea to avoid the DOM at all costs yeah?</p>
<p>Not really. Whether developers like it or not the DOM is an integral part of the browser and your Javascript code base. Avoiding it while testing is simply going to make the pendulum swing the other way. <strong>You&#8217;ll end up with specs which mean almost nothing</strong>.</p>
<p>Check out this example. Its obvious that there is a selection of an element being made and the wrap function is being called.</p>
<div style="border:1px solid #CCC;font-size:13px;margin:10px;padding:10px;">
<pre>
<span style="color:green;">// Implementation</span>
function highlightingARow() {
    $(<span style="color:green;">'.row:first'</span>).wrap(<span style="color:green;">'&lt;div class="highlight" /&gt;'</span>);
}

<span style="color:green;">// Spec</span>
it(<span style="color:green;">'should highlight the first row'</span>,  function() {
    highlightingARow();
    $.usingSelector(<span style="color:green;">'.row:first'</span>).should(<span style="color:green;">'wrap'</span>);
});
</pre>
</div>
<p>The important part in all of this is not that the wrap function is called, but that the element selected actually has the right element wrapped around it. I&#8217;ve chosen an example that would require (I guess) some difficulty to implement across multiple browsers. I&#8217;ve seen Internet Explorer do some wonderful things with the wrap function, to the point where it had to be implemented differently altogether. With a mocked out jQuery, this spec would never had failed!</p>
<p>Because jQuery has been told to do something doesn&#8217;t mean it has done it properly. It&#8217;s much better to assert against what actually happened, which means checking the DOM after the jQuery call of course.</p>
<p>And, once again, upgrading jQuery? How confident would you be with replacing an old version of jQuery with a new one, running all your tests with a mocked out jQuery and seeing all your tests pass? Like I said before, jQuery is a giant Javascript DSL. More specifically, a DSL for the DOM.</p>
<h2>Mocking jQuery means no TDD</h2>
<p>Developers love to boast the fact that they follow many of the Extreme Programming (XP) practices like <a href="http://en.wikipedia.org/wiki/Pair_programming" target="_blank">Pair Programming</a>, <a href="http://en.wikipedia.org/wiki/Continuous_integration" target="_blank">Continuous Integration</a> and <a href="http://en.wikipedia.org/wiki/Test-driven_development" target="_blank">Test Driven Development (TDD)</a>. Not surprisingly, for various reasons its hard(er) to achieve some of these practices in Javascript land. What I want to focus on here is TDD.</p>
<p>Once again, here is the wrap example</p>
<div style="border:1px solid #CCC;font-size:13px;margin:10px;padding:10px;">
<pre>
<span style="color:green;">// Implementation</span>
function highlightingARow() {
    $(<span style="color:green;">'.row:first'</span>).wrap(<span style="color:green;">'&lt;div class="highlight" /&gt;'</span>);
}

<span style="color:green;">// Spec</span>
it(<span style="color:green;">'should highlight the first row'</span>,  function() {
    highlightingARow();
    $.usingSelector(<span style="color:green;">'.row:first'</span>).should(<span style="color:green;">'wrap'</span>);
});
</pre>
</div>
<p>Its easy to see that what&#8217;s specified in the test is very close to what is described in the implementation. Let me ask this question. Are you going to write the implementation first, refresh your server (if you have to, this is where I have much love for rails) and jump on the browser and verify what you have written is correct? or are you going to write the spec first, then do all those things? jQuery involves plenty of tinkering and will take a few goes to get it right. It would take a jQuery genius to get any benefit out of writing tests first, at least when mocking jQuery is involved. Therefore it would be more beneficial to write a spec which describes what the DOM should look like once the code has been executed, then you can tinker until the spec passes no?</p>
<h2>Mocking jQuery is &#8230;</h2>
<p>I only thought of four things, and instead of changing the heading of the post to &#8220;Four reasons to avoid mocking jQuery&#8221; I decided to keep it at five because it is a round enough number. That and I&#8217;m a bit of a bullshit artist. If I think of a fifth one I&#8217;ll post it I swear. A friend of mine put it perfectly, I&#8217;m simply TDD&#8217;ing (Title Driven Development, no wiki page for that one sorry).</p>
<h2>What&#8217;s the answer?</h2>
<p>It comes back to what I spoke about originally in regards to integration tests, unit tests, and the other use of mocks. Some of us decided that the best what to unit test our Javascript is to mock out all dependencies, whether its dependencies we created or other API&#8217;s like jQuery. If we are dealing with unit tests then MAYBE mocking out jQuery is a good thing. But I&#8217;m not that big a fan of unit tests when it doesn&#8217;t make sense. I can assure you there is minimal gain in mocking out jQuery. <strong>If you are testing code that requires DOM interaction in anyway, then it should be classified as an integration test and interact with the DOM as expected.</strong></p>
<p>Now that I am not mocking jQuery any more, here is the same wrap() example from earlier but re-jigged slightly, hopefully highlighting the benefits of taking such an approach. The syntax I am using is similar to what will be implemented in MimicJS soon enough.</p>
<div style="border:1px solid #CCC;font-size:13px;margin:10px;padding:10px;">
<pre>
<span style="color:green;">// Implementation</span>
function highlightingARow() {
    $(<span style="color:green;">'.row:first'</span>).wrap(<span style="color:green;">'&lt;div class="highlight" /&gt;'</span>);
}

<span style="color:green;">// Spec</span>
it(<span style="color:green;">'should highlight the first row'</span>,  function() {
    $(<span style="color:green;">'body'</span>).empty().append(<span style="color:green;">'&lt;div class="row"/&gt;'</span>).append(<span style="color:green;">'&lt;div class="row"/&gt;'</span>);

    when.    highlightingARow();
    then.    expect($(<span style="color:green;">'row:first'</span>)).toHaveParent($(<span style="color:green;">'.highlight'</span>));
});
</pre>
</div>
<p>As you can see I have a slightly more verbose test. I have used jQuery itself to set up the test data and have got my expectations based on the state of the DOM and not the behaviour of jQuery. Let&#8217;s revisit the four points above and see the benefits.</p>
<p><strong>Mocking jQuery is hard to do</strong>. Not much to add here as there is no mocking going on. I can assure you though its much easier to add matchers such as &#8216;toHaveParent&#8217; than it is to mock jQuery nicely.</p>
<p><strong>Mocking jQuery means fragile tests</strong>. If I change my implementation to use a different framework or the name of the wrap function happens to change, then from what I can see my spec is still going to pass. Provided the first row has the parent highlight I dont really care how it is implemented, as long as the state of the DOM at the end is correct.</p>
<p><strong>Mocking jQuery means zero DOM interactions</strong>. The issues here have been squashed completely. Because there is no mocking going on means we are interacting with the DOM, which is a good thing. We can upgrade jQuery and be confident the highlight feature hasn&#8217;t change its behaviour. We also have more flexibility when it comes to testing across multiple browsers. If the wrap function is broken in IE for example then there will be specs failing for IE and not other browsers. &#8220;reality&#8221; is tested.</p>
<p><strong>Mocking jQuery means no TDD</strong>. It&#8217;s obvious when we are mocking out jQuery line for line that there is next to no TDD&#8217;ing going on. A trivial example like this its nice to be able to implement test driven, even if only to make yourself feel less dodgy when writing it. Going test driven can be tough for developers, no need to make it tougher by mocking out something as tightly coupled as jQuery.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/azzamallow.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/azzamallow.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/azzamallow.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/azzamallow.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/azzamallow.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/azzamallow.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/azzamallow.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/azzamallow.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/azzamallow.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/azzamallow.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/azzamallow.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/azzamallow.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/azzamallow.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/azzamallow.wordpress.com/95/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azzamallow.wordpress.com&amp;blog=14211211&amp;post=95&amp;subd=azzamallow&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://azzamallow.wordpress.com/2010/06/28/five-reasons-to-avoid-mocking-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/269fbba1332d69ee4db95c4c8fb3af9c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">azzamallow</media:title>
		</media:content>
	</item>
		<item>
		<title>The NBA, iPhone and the Open Web</title>
		<link>http://azzamallow.wordpress.com/2010/06/16/the-nba-iphone-and-the-open-web/</link>
		<comments>http://azzamallow.wordpress.com/2010/06/16/the-nba-iphone-and-the-open-web/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 13:54:11 +0000</pubDate>
		<dc:creator>azzamallow</dc:creator>
				<category><![CDATA[NBA]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://azzamallow.wordpress.com/?p=27</guid>
		<description><![CDATA[An introduction In an effort to keep things light-hearted/introduce myself to the masses, I thought what better to write about than my two passions in life, basketball and IT. This blog entry will also double as the first of many which document a journey, if I somehow produce what I&#8217;m about to propose of course [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azzamallow.wordpress.com&amp;blog=14211211&amp;post=27&amp;subd=azzamallow&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>An introduction</h2>
<div id="attachment_68" class="wp-caption alignright" style="width: 248px"><img class="size-full wp-image-68  " title="azzamallow" src="http://azzamallow.files.wordpress.com/2010/06/azzamallow22.png?w=238&#038;h=326" alt="" width="238" height="326" /><p class="wp-caption-text">What could have been?</p></div>
<p>In an effort to keep things light-hearted/introduce myself to the masses, I thought what better to write about than my two passions in life, basketball and IT. This blog entry will also double as the first of many which document a journey, if I somehow produce what I&#8217;m about to propose of course (don&#8217;t count on it, but it sounds like a good idea RIGHT NOW).</p>
<p>I wont waffle on for too long, but I will state that I spent much of my childhood glued to <a onclick="return mugicPopWin(this,event);" oncontextmenu="mugicRightClick(this);" title="basketball videos" href="http://www.amazon.com/Michael-Jordan-Come-Fly-VHS/dp/6305337977" target="_blank">basketball videos</a>, <a onclick="return mugicPopWin(this,event);" oncontextmenu="mugicRightClick(this);" title="the same ones" href="http://www.amazon.com/Michael-Jordans-Playground-VHS-Jordan/dp/6301920996" target="_blank">the same ones</a>, <a onclick="return mugicPopWin(this,event);" oncontextmenu="mugicRightClick(this);" title="over and over" href="http://www.amazon.com/Michael-Jordan-Air-Time-VHS/dp/6305337934" target="_blank">over and over</a>, dreaming of playing professionally one day. It wasn&#8217;t until I was reaching the latter stages of high school (and realised that I wasn&#8217;t going to be Michael Jordan) that IT became a big part of my life.</p>
<p>I follow basketball religiously. I check the scores, watch for trades, <a onclick="return mugicPopWin(this,event);" oncontextmenu="mugicRightClick(this);" href="http://www.amazon.com/Book-Basketball-NBA-According-Sports/dp/034551176X/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1276695326&amp;sr=8-1" target="_blank">read the books</a>, understand the history and understand the game. So while I will write mostly about techy stuff in this blog, my loyalties are equally as strong with the sport and you will find traces of hoops in what I write. After all, it does keep things a little more interesting for the writer :)</p>
<p>Now lets marry the two together.</p>
<p>As a developer I&#8217;m constantly thinking about cool and innovative things I can create. As most developer will attest to its easy to get caught up in something you are passionate about, sometimes even going to the length of doing more than thinking about it. In the end you mostly have a half complete job, at least that&#8217;s what I end up with. This was a big driver for me starting this blog as well, because I know that ill burn out after the initial excitement and end up with not much at all. At least through writing I get the thought documented for everyone to see (well at this point it will just be the people I force to read my blog :)).<br />
&nbsp;</p>
<h2>The Problem</h2>
<div id="attachment_56" class="wp-caption alignleft" style="width: 266px"><img class="size-full wp-image-56 " title="The Box Score from my iPhone." src="http://azzamallow.files.wordpress.com/2010/06/nba-box-score1.jpg?w=256&#038;h=384" alt="The Box Score from my iPhone." width="256" height="384" /><p class="wp-caption-text">The Box Score from my iPhone.</p></div>
<p>When a basketball game is on I&#8217;m glued to the box scores and twitter, from my iPhone mostly. It&#8217;s frustrating as hell looking at <a title="Yahoo! Sports" href="http://sports.yahoo.com/nba" target="_blank">Yahoo! Sports</a> from my phone. I can never seem to zoom to the good stuff quickly enough, and find myself constantly zoomed at a specific section of the page. And NBA iPhone apps? There is not much out there (at least in the Australian store) and what is there is pretty crap to be honest. I haven&#8217;t found anything web-based that offers something better than the box scores on the major sports websites.</p>
<p>So&#8230;why not make my own?</p>
<p>YES!</p>
<p>Oh wait, I&#8217;ll get lazy and wont finish it, that&#8217;s right. Lets just crap on about it here instead (not to say I wont hack around, I will).</p>
<p>With the iPad&#8217;s recent introduction to market, the big push from Google (with Google Chrome and Android) and a few <a href="http://www.google.com.au/search?hl=en&amp;safe=off&amp;tbs=vid:1&amp;q=google+io+2010+youtube&amp;aq=f&amp;aqi=&amp;aql=&amp;oq=&amp;gs_rfai=" target="_blank">inspirational keynotes</a>, <a href="http://en.wikipedia.org/wiki/HTML5" target="_blank">HTML5</a> seems to have finally hit the technology mainstream. That means its time for me to get off my ass and read up about this stuff (which I have been doing), start dreaming up ideas and be part of the push for a better web.</p>
<p>For the record I never used to give the web enough credit on devices like the iPhone, and was always thinking in native application terms. That&#8217;s all gone now thanks to the iPad. It aims to offer a web experience unlike anything we can get on other devices, and appears equipped enough to make that happen. Six months ago I may have been thinking about my dream native iPhone NBA application, however the web is too powerful, too flexible and too open to ignore. Hence now I would only ever go down the native app road if it was an absolute necessity.</p>
<p>What is this HTML5 powered page going to do?</p>
<p>Here&#8217;s a quick rundown. A snapshot of how this (lets call it an application) is going to work.</p>
<ul>
<li>Screen-scrape the results off an NBA site, strictly for proof of concept. The data has to come from somewhere right? This is quite easy to achieve with Ruby, therefore let&#8217;s make the back-end a Ruby on Rails application,</li>
<li>Strictly define the markup. It&#8217;s important to not get caught writing unnecessary HTML as it will make it harder to make this thing work across multiple platforms,</li>
<li>CSS3 and lots of it. This is important for the same reason as writing strict HTML, plus the fact that you can do cool enough stuff that the use of images on the page can be minimised,</li>
<li>iPhone and iPad (and maybe <a href="http://www.google.com/tv/" target="_blank">Google TV</a>?) capable. Keeping this in mind is important as it greatly influences how the application is created,</li>
<li>Some form of video (maybe a <a href="http://www.youtube.com/user/nba?blend=1&amp;ob=4" target="_blank">YouTube subscription</a> which shows highlights of the days games).</li>
<li>No scrolling, full screen (easy enough),</li>
<li><a href="http://en.wikipedia.org/wiki/DOM_storage" target="_blank">HTML5 Web storage</a> via local database. Allowing the capability of caching the play-by-play (when the users exits and re-enters the application), even complete box scores of previous games,</li>
<li>The use of <a href="http://en.wikipedia.org/wiki/Canvas_element" target="_blank">Canvas 2D</a>, for drawing any specific shapes that may be needed for the application,</li>
<li>A different experience on the iPhone compared to the iPad, they are different platforms afterall.</li>
</ul>
<h2>Now what?</h2>
<p>Well, I may as well start hacking away and see what I can produce! I&#8217;ll do bits and pieces and post my findings along to way. Future posts will reveal more of course.</p>
<p>Thanks for reading and hello!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/azzamallow.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/azzamallow.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/azzamallow.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/azzamallow.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/azzamallow.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/azzamallow.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/azzamallow.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/azzamallow.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/azzamallow.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/azzamallow.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/azzamallow.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/azzamallow.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/azzamallow.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/azzamallow.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azzamallow.wordpress.com&amp;blog=14211211&amp;post=27&amp;subd=azzamallow&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://azzamallow.wordpress.com/2010/06/16/the-nba-iphone-and-the-open-web/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/269fbba1332d69ee4db95c4c8fb3af9c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">azzamallow</media:title>
		</media:content>

		<media:content url="http://azzamallow.files.wordpress.com/2010/06/azzamallow22.png" medium="image">
			<media:title type="html">azzamallow</media:title>
		</media:content>

		<media:content url="http://azzamallow.files.wordpress.com/2010/06/nba-box-score1.jpg" medium="image">
			<media:title type="html">The Box Score from my iPhone.</media:title>
		</media:content>
	</item>
		<item>
		<title>Dont hurt me</title>
		<link>http://azzamallow.wordpress.com/2010/06/15/dont-hurt-me/</link>
		<comments>http://azzamallow.wordpress.com/2010/06/15/dont-hurt-me/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 09:19:01 +0000</pubDate>
		<dc:creator>azzamallow</dc:creator>
				<category><![CDATA[Unimaginative]]></category>

		<guid isPermaLink="false">http://azzamallow.wordpress.com/?p=6</guid>
		<description><![CDATA[Welcome to my blog, and here is my first post. Much more interesting and exciting stuff to follow soon. Until then I will tinker with the look and feel of the site<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azzamallow.wordpress.com&amp;blog=14211211&amp;post=6&amp;subd=azzamallow&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Welcome to my blog, and here is my first post.</p>
<p>Much more interesting and exciting stuff to follow soon. Until then I will tinker with the look and feel of the site</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/azzamallow.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/azzamallow.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/azzamallow.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/azzamallow.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/azzamallow.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/azzamallow.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/azzamallow.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/azzamallow.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/azzamallow.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/azzamallow.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/azzamallow.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/azzamallow.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/azzamallow.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/azzamallow.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azzamallow.wordpress.com&amp;blog=14211211&amp;post=6&amp;subd=azzamallow&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://azzamallow.wordpress.com/2010/06/15/dont-hurt-me/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/269fbba1332d69ee4db95c4c8fb3af9c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">azzamallow</media:title>
		</media:content>
	</item>
	</channel>
</rss>
