iainjmitchellThe website of iainjmitchell, a Software Practitioner from Manchester UK.
http://iainjmitchell.com/
Mon, 08 Oct 2018 19:52:04 +0000Mon, 08 Oct 2018 19:52:04 +0000Jekyll v3.7.4Mono No Aware (物の哀れ)<p>The <a href="https://plato.stanford.edu/entries/japanese-aesthetics/">Stanford Encyclopedia of Philosophy</a> defines <strong>mono no aware</strong> as</p>
<blockquote>
<p>a “pathos” (aware) of “things” (mono), deriving from their transience</p>
</blockquote>
<p>The term was constructed by <a href="https://en.wikipedia.org/wiki/Motoori_Norinaga">Motoori Norinaga</a> in the eighteenth century to encapsulate the mood which was central to the Japanese. This was particularly focussed upon the impermanence of things and a slightly melancholy awareness of this. But there is also a quiet rejoicing as our awareness allows us the opportunity to witness the beauty in these.</p>
<p>The annual sakura (Cherry blossom) in Japan is a good example of <strong>mono no aware</strong>. Every year thousands of Japanese families visit parks to witness and celebrate the mere days of sakora. Before it falls from the trees and is no more. I recommend the excellent book <a href="https://www.amazon.co.uk/Hokkaido-Highway-Blues-Hitchhiking-Japan/dp/1841952885">Hokkaido Highway Blues</a> if you want to learn more about this part of Japanese culture.</p>
<p>So why am I writing about <strong>mono no aware</strong> in my software blog?</p>
<p>After reading about this term I looked at my day-to-day life through the lenses of <strong>mono no aware</strong> and realised this philosophy could be applied to software engineering.</p>
<p>We should think about the products we build as impermanent. Often we go into building new products with a sense that they will be serving their purpose for many years to come, happly ticking along. But we know this is not the norm, most products have a lifecycle of mere years. So perhaps we should build our products for the here and now and resist the temptation to future proof and crystal ball.</p>
<p>If we accept that our products are impermanent, then this will lead to a fleeting awareness our users will have of our products. This highlights the importance of releasing early to ensure they see the beauty of the products for as long as possible.</p>
<p>This understanding of transience can also be applied to our code. We often write tests to help build and understand the product, but often there is a reluctance to delete those which no longer have any value. Even though we may have mentally sweated to create these tests we should be prepared to let them go. They have served their benefit and we have briefly enjoyed their beauty.</p>
<p>Accepting the codes impermanence will also help us to be less precious about changes that others make to code that we have worked on. In both commercial teams and open source projects we see examples of individuals who re-write, rollback and change others commits. As engineers we should be prepared to let others shape the code to their world view. Even if it means losing code that we have been proud of. Thanks to version control you can always go back and revisit it - like a photo of the sakura.</p>
<p><img src="/images/sakura.jpg" alt="Sakura" /></p>
Tue, 04 Apr 2017 12:39:51 +0000http://iainjmitchell.com/blog/mono-no-aware
http://iainjmitchell.com/blog/mono-no-awareSoftwarePhilosophyDunning-Kruger Effect in Software Development<p>In 1999 a paper by Justin Kruger and David Dunning of Cornell University appeared in the <strong>Journal of Personality and Social Psychology</strong>, this piece summarised research that they had been carried out into the difference between peoples perceived and actual ability in a subject.</p>
<p>Here is a particularly amusing account of stupidity that is mentioned within the paper:</p>
<blockquote>
<p>In 1995, McArthur Wheeler walked into two Pittsburgh banks
and robbed them in broad daylight, with no visible attempt at
disguise. He was arrested later that night, less than an hour after
videotapes of him taken from surveillance cameras were broadcast
on the 11 o’clock news. When police later showed him the surveillance
tapes, Mr. Wheeler stared in incredulity. “But I wore the
juice,” he mumbled. Apparently, Mr. Wheeler was under the
impression that rubbing one’s face with lemon juice rendered it
invisible to videotape cameras</p>
</blockquote>
<p>The third study of the paper focused upon recording perceived and actual test scores of students and it resulted in their famous graph.</p>
<p><img src="/images/dunning-kruger.png" alt="Dunning-Kruger Graph" /></p>
<p>This graph suggests that people who have less knowledge of a subject actual think they know more than some of those more informed. Quite simply put, they are too unskilled to be aware of it, and this is what is known as the <strong>Dunning-Kruger Effect</strong>.</p>
<p>So, how does this fit in with Software Development? I’ve seen the <strong>Dunning-Kruger Effect</strong> play out in following three ways:</p>
<h2 id="1-inexperienced-developers">1. Inexperienced Developers</h2>
<p>We’ve all been there, looking back I feel sorry for the developers who had to work with me in my first few years in the industry!</p>
<p>This only becomes a problem for the developer in question if they decide that they know enough and stop learning. By learning I don’t mean the latest Javascript framework, I mean perfecting their art and looking to improve by learning from their mistakes. Such developers are often labeled <strong>9 to 5 developers</strong>, but it’s not about working hours, it’s that they will do the bare minimum to continue getting paid.</p>
<p>It is also important that inexperienced developers should get to work day to day with more experienced colleagues, ideally through pairing. This will help rapidly improve their knowledge and appreciate what they don’t know.</p>
<h2 id="2-impostor-syndrome">2. Impostor syndrome</h2>
<p>More experienced developers can suffer from <a href="http://en.wikipedia.org/wiki/Impostor_syndrome">Impostor Syndrome</a> which gives them the impression that they know less than they do. Mixed with confident vocal inexperienced developers this may result in poor decisions being made.</p>
<p>Impostor Syndrome can also cause people to overwork, so that they avoid being detected as an impostor. This can lead to burn-out which is a serious problem in the IT industry.</p>
<h2 id="3-unknowledgeable-non-technical-team-members">3. Unknowledgeable Non-Technical Team Members</h2>
<p>In Ben Goldacre’s excellent book <a href="http://en.wikipedia.org/wiki/Bad_Science_%28book%29">Bad Science</a> he claims that the media’s flawed coverage of the MMR vaccine scare was a result of journalists falling prey to the <strong>Dunning-Kruger Effect</strong>. They did not understand anything about medical research and statistics to recognise that the study that suggested the link between autism and the vaccine was laughably weak.</p>
<p>There is also a similar problem with non-technical team members, which can be particularly troublesome if they have client contact. In one case I have seen a Project Manager was discussing everything from <strong>divs</strong> to <strong>merging strategies</strong> with the client. They then took the results of the discussion and presented it to the development team as tasks. Unsurprisingly poor decisions had been made and the solution failed to meet the client goal.</p>
<p>As developers we can contribute to this by engaging in pseudo-technical conversations with non-technical team members. If you keep using branches and html elements in conversation people will pick up this terminology and use it. This will start to empower them to make ill-informed technical decisions which will lead to a culture of technical tasks rather than problem solving.</p>
<hr />
<p>Dunning and Kuger’s full paper can be read here:</p>
<p><a href="http://www.jerwood-no.org.uk/pdf/Dunning%20Kruger.pdf">Unskilled and Unaware of It: How Difficulties in Recognizing One’s Own
Incompetence Lead to Inflated Self-Assessments</a></p>
Mon, 23 Feb 2015 12:39:51 +0000http://iainjmitchell.com/blog/dunning-kruger
http://iainjmitchell.com/blog/dunning-krugermanagement,agileFull stack testing with gulp & zombie<p>For the latest nodejs website I’ve been working on, I wanted to write a couple of full stack tests using the headless browser <a href="http://zombie.labnotes.org/">zombie</a>. I also wanted to automate the running of these tests using the task runner <a href="http://gulpjs.com/">gulp</a>.</p>
<blockquote>
<p>N.B. If you want to try any of the following examples, you’ll need the following packages from NPM:</p>
</blockquote>
<blockquote>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>npm install zombie <span class="nt">--save-dev</span>
npm install gulp <span class="nt">--save-dev</span>
npm install gulp-mocha <span class="nt">--save-dev</span>
npm install gulp-develop-server <span class="nt">--save-dev</span>
</code></pre></div> </div>
</blockquote>
<p>I decided to write my tests using <a href="http://mochajs.org/">Mocha</a>, though alternatively you can use pretty much any other node testing framework. Here is an example of one my tests:</p>
<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">var</span> <span class="nx">Browser</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'zombie'</span><span class="p">);</span>
<span class="nx">describe</span><span class="p">(</span><span class="s1">'Full stack scenarios'</span><span class="p">,</span> <span class="kd">function</span><span class="p">(){</span>
<span class="k">this</span><span class="p">.</span><span class="nx">timeout</span><span class="p">(</span><span class="mi">10000</span><span class="p">);</span>
<span class="nx">Browser</span><span class="p">.</span><span class="nx">localhost</span><span class="p">(</span><span class="s1">'mySite'</span><span class="p">,</span> <span class="mi">3000</span><span class="p">);</span>
<span class="nx">describe</span><span class="p">(</span><span class="s1">'When we navigate to the index page'</span><span class="p">,</span> <span class="kd">function</span><span class="p">(){</span>
<span class="kd">var</span> <span class="nx">browser</span> <span class="o">=</span> <span class="nx">Browser</span><span class="p">.</span><span class="nx">create</span><span class="p">();</span>
<span class="nx">before</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">done</span><span class="p">){</span>
<span class="nx">browser</span><span class="p">.</span><span class="nx">visit</span><span class="p">(</span><span class="s1">'/'</span><span class="p">,</span> <span class="nx">done</span><span class="p">);</span>
<span class="p">});</span>
<span class="nx">it</span><span class="p">(</span><span class="s1">'Then the title is correct'</span><span class="p">,</span> <span class="kd">function</span><span class="p">(){</span>
<span class="nx">browser</span><span class="p">.</span><span class="nx">assert</span><span class="p">.</span><span class="nx">text</span><span class="p">(</span><span class="s1">'title'</span><span class="p">,</span> <span class="s1">'Fisherprice My First Website'</span><span class="p">);</span>
<span class="p">});</span>
<span class="p">});</span>
<span class="p">});</span>
</code></pre></div></div>
<p>Zombie provides a Browser object that allows you to access locally hosted sites, the <strong>localhost()</strong> function gives the port number of the site and an alias that zombie will use instead of localhost in the url.</p>
<p>In the <strong>before()</strong> function of the Mocha test I instruct the browser to visit the root of the website, once this is done (it’s asynchronous) it falls into the function which asserts on the sites title. This is using the built in assert functionality within Zombie’s browser object (I’m not 100% sure about whether I like this, it feels like Zombie has too many responsibilities).</p>
<p>So, that’s the test written, we just have to automate the running of this via gulp. The problem with automating full-stack tests through a task runner is that you need to ensure the website is running locally before the tests are run. We also need to tear down the website after the tests have been run.</p>
<p>Therefore our full-stack testing work flow is like this:</p>
<ol>
<li>Start website</li>
<li>Run tests</li>
<li>Stop website (if tests pass or fail)</li>
</ol>
<p>Below is an interpretation of this in gulp…</p>
<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">var</span> <span class="nx">gulp</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'gulp'</span><span class="p">),</span>
<span class="nx">mocha</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'gulp-mocha'</span><span class="p">),</span>
<span class="nx">server</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span> <span class="s1">'gulp-develop-server'</span><span class="p">);</span>
<span class="nx">gulp</span><span class="p">.</span><span class="nx">task</span><span class="p">(</span><span class="s1">'scenarios'</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="nx">server</span><span class="p">.</span><span class="nx">listen</span><span class="p">(</span> <span class="p">{</span> <span class="na">path</span><span class="p">:</span> <span class="s1">'./server.js'</span> <span class="p">});</span>
<span class="k">return</span> <span class="nx">gulp</span>
<span class="p">.</span><span class="nx">src</span><span class="p">(</span><span class="s1">'scenarios/*'</span><span class="p">,</span> <span class="p">{</span><span class="na">read</span><span class="p">:</span> <span class="kc">false</span><span class="p">})</span>
<span class="p">.</span><span class="nx">pipe</span><span class="p">(</span><span class="nx">mocha</span><span class="p">({</span><span class="na">reporter</span><span class="p">:</span> <span class="s1">'nyan'</span><span class="p">}))</span>
<span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">'error'</span><span class="p">,</span> <span class="kd">function</span><span class="p">(){</span>
<span class="nx">server</span><span class="p">.</span><span class="nx">kill</span><span class="p">();</span>
<span class="p">})</span>
<span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">'end'</span><span class="p">,</span> <span class="kd">function</span><span class="p">(){</span>
<span class="nx">server</span><span class="p">.</span><span class="nx">kill</span><span class="p">();</span>
<span class="p">});</span>
<span class="p">});</span>
</code></pre></div></div>
<p>For control of the nodejs website I am using a gulp plugin called <strong>gulp-develop-server</strong>, this is initially used to start the website by calling <strong>server.listen()</strong>. The path in the option is the js file that starts the nodejs webserver.</p>
<p>Once the website is started the <strong>gulp.src()</strong> function is used to load the test files from the specified directory, in this case it is the scenarios subdirectory. I have specified the option to NOT read the files at this point, so gulp will just pipe a list of the files it finds in this location.</p>
<p>Next in the pipeline is the mocha object from <strong>gulp-mocha</strong>, this will execute mocha on each of the test files piped to it. I’m using the nyan cat reporter for mocha because for some reason I still find an ASCII rendering of a nyan cat amusing.</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>1 <span class="nt">-__</span>,------,
0 <span class="nt">-__</span>| /<span class="se">\_</span>/<span class="se">\ </span>
0 <span class="nt">-_</span>~|_<span class="o">(</span> ^ .^<span class="o">)</span>
<span class="nt">-_</span> <span class="s2">""</span> <span class="s2">""</span>
</code></pre></div></div>
<p>The final part of the gulp task is to ensure that the website is stopped at the end of test run. Fortunately, <strong>gulp-develop-server</strong> provides a function called <strong>kill()</strong> to terminate the site. To ensure that this is run, regardless of whether the tests passed or failed, I have included a call to <strong>server.kill()</strong> in both the ‘end’ and ‘error’ event handlers.</p>
<p>Now we should be able to execute our full stack tests by running the following in the shell:</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code> gulp scenarios
</code></pre></div></div>
Wed, 28 Jan 2015 16:39:51 +0000http://iainjmitchell.com/blog/full-stack-testing
http://iainjmitchell.com/blog/full-stack-testingnodejs,gulpProjects<blockquote>
<p>In contemporary business and science a <strong>project</strong> is defined as a collaborative enterprise, involving research or design, that is <strong>carefully planned</strong> to achieve a particular aim.</p>
</blockquote>
<p><em>Oxford English Dictionary</em></p>
<blockquote>
<p>This agile stuff seems to work fine for defects and BAU (Business As Usual) work, but it doesn’t seem to fit for project work</p>
</blockquote>
<p><em>Anonymous team member</em></p>
<h1 id="what-is-the-difference-between-bau-and-project-development-work">What is the difference between BAU and project development work?</h1>
<p>They both involve changes to the software, maybe to a database, hopefully they are tested and then they are released out in the wild. Except usually the project work is not released out into the wild, it sits there waiting for the rest of the project to be finished or it is released <a href="http://en.wikipedia.org/wiki/Feature_toggle">feature switched</a> off.</p>
<p>Sometimes project development work cannot be released because it is non-releasable, for example a ‘front-end’ ticket that also requires the ‘back-end’ ticket to be completed before releasing.</p>
<h1 id="what-is-the-difference-between-bau-and-projects-from-a-client-perspective">What is the difference between BAU and projects from a client perspective?</h1>
<p>BAU is a small change, perhaps based upon a metric or upcoming promotion that can potentially have immediate return on investment.
Projects are usually a big sweeping change, more likely to be based upon hunches and opinions of individuals. These maybe correct, but they cannot be measured until the end of the project.</p>
<p>Projects are also a much bigger investment for a client, so it is understandable that they want to know what they are getting and how much it’ll cost.</p>
<p>#What is the difference between BAU and projects from a management perspective?
Projects need more management, from providing costs to tracking progress and risk. BAU is more light touch - the client or metrics drive the change.</p>
<p>Because of the extra management, the costs of project will be much higher. Due to the size and increased risk they are also likely to be more inefficient. Some companies will even pass some of this cost back to clients as a management charge.</p>
<h1 id="so-why-do-we-have-projects">So why do we have projects?</h1>
<p>Some non-technical people still have a house-building notion of software development. They think that they have to build the entire extension, not realising that we could just put up a sign first to see if anyone actually wants an extension.</p>
<p>Unfortunately, projects are also championed from an accountancy point of view as the cost of a software project can be depreciated over a four year period. This means the investment they made into the project can be spread over this period, which can be beneficial from a tax point of view.</p>
<p>There are also some cases where a project is appropriate, for example a piece of work that requires changes by multiple teams perhaps including non-software changes (e.g. hardware).</p>
<h1 id="how-do-we-get-away-from-projects">How do we get away from projects?</h1>
<p>I’ve often heard people blame clients for enforcing a project based approach, but I have also witnessed sales representatives set expectations for the style of working in early negotiations. This suggests to truly get away from projects, it requires full organisational change.</p>
<p>If this is out of reach, a first step could be to ensure that all work coming into the team is independently testable and releasable. This is following the principle of Continuous Delivery, this states that you should always be in a position to release to live - even if the client doesn’t want to (not to be confused with Continuous Deployment which is constantly releasing changes to live). It will also hopefully help get the client and other people within the organisation to start seeing that small incremental changes are possible.</p>
<p>As for the accountancy benefits of running software changes through projects, I have to admit I am no expert in this area, though I do wonder whether vague projects could be established (e.g. website quarter 3 work) that all the work through this period could be attached to.</p>
Thu, 08 Jan 2015 10:39:51 +0000http://iainjmitchell.com/blog/projects
http://iainjmitchell.com/blog/projectsagile,leanChess<p>Over the last few days I’ve been attempting to discover the objects and interactions for the game of chess. After writing down the basic rules of pawns I identified the following candidate objects, using noun analysis:</p>
<ul>
<li>Pawn</li>
<li>Square</li>
<li>Piece</li>
<li>Board</li>
<li>Game</li>
<li>Move</li>
</ul>
<p>Using these I’ve run a couple of <a href="http://en.wikipedia.org/wiki/Class-responsibility-collaboration_card">CRC card</a> sessions to try and work out the objects, their responsibilities and interactions. I’m trying to model the game in a strict Object Orientated fashion, by protecting object state by following the principle of <a href="https://pragprog.com/articles/tell-dont-ask">Tell Don’t Ask</a>.</p>
<p>The issue I am having is seems that the pawn should have the responsibility of looking after it’s rules of movement. BUT some of the rules are dependent on the state of the board. For example, a pawn cannot move one space forward if there is another piece in the way.</p>
<p>I did play around with the idea that the pawn could approve this move, tell the board of the intention and then the board could block the move. However, this does not work with a second scenario I ran through. This involved moving the pawn diagonally to the left, which is only legal if an opposition piece occupies the square.</p>
<p>This seems to suggest that the state of the board has to be shared with all the pieces, if they are to enforce their own rules of movement. I’m not really happy with this, so I’d welcome any alternative suggestions</p>
Wed, 31 Dec 2014 13:00:51 +0000http://iainjmitchell.com/blog/chess
http://iainjmitchell.com/blog/chessCRC,OOIsomorphism<p>Recently I’ve been reading a fascinating book by Douglas Hofstadter called <a href="http://en.wikipedia.org/wiki/G%C3%B6del,_Escher,_Bach">Gödel, Escher, Bach</a>. In an early chapter he introduces the concept of <em>Formal Systems</em>, which is any system of abstract thought based upon the model of mathematics.</p>
<p>Further into the book a Formal System called the PQ-system is proposed.</p>
<blockquote>
<p><strong>DEFINITION:</strong></p>
</blockquote>
<blockquote>
<p><em>x</em>P-Q<em>x</em>- is an <a href="http://en.wikipedia.org/wiki/Axiom">axiom</a>, whenever <em>x</em> is composed of hyphens only.</p>
</blockquote>
<blockquote>
<p><strong>RULE OF PRODUCTION:</strong></p>
</blockquote>
<blockquote>
<p>Suppose <em>x</em>, <em>y</em> and <em>z</em> all stand for particular strings containing only hyphens.<br />
And suppose that <em>x</em>P<em>y</em>Q<em>z</em> is known to be a theorem.<br />
Then <em>x</em>P<em>y</em>-Q<em>z</em>- is a theorem.</p>
</blockquote>
<p>The author then asks the reader to discover the <a href="http://en.wikipedia.org/wiki/Decision_problem">decision procedure</a> of the formal system, which is revealed to be that the first two hypen groups should add up, in length, to the third hypen group.</p>
<p>So <a href="http://en.wikipedia.org/wiki/Theorem">theorems</a> would include:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>--P---Q-----
-P--Q---
-P---Q----
</code></pre></div></div>
<p>And would not include:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>--P--Q-
-P-Q---
</code></pre></div></div>
<p>You may have noticed that effectively this formal system is about adding two numbers together, the - represents a count and the number of these either side of the P add up to the number after the Q. So, the theorem –P—Q—– is equivalent to 2 + 3 = 5.</p>
<p>This leads us to an interesting discovery, does the symbol P actual mean ‘Plus’ and the symbol Q mean ‘eQuals’? This is an example of isomorphism, we are attaching a real world meaning to a symbol in a Formal System.</p>
<p>But are our isomorphic assumptions correct? Does it influence our discovery of the Decision Procedure and thus the entire Formal System?</p>
<p>Programming languages are a form of Formal Systems, so it’s unsurprising that this same problem plays out in the code we write. Take the following example of LINQ (stolen from a Microsoft example).</p>
<div class="language-csharp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">people</span><span class="p">.</span><span class="nf">Select</span><span class="p">(</span><span class="n">p</span> <span class="p">=&gt;</span> <span class="k">new</span> <span class="p">{</span> <span class="n">Name</span> <span class="p">=</span> <span class="n">p</span><span class="p">,</span> <span class="n">p</span><span class="p">.</span><span class="n">Length</span> <span class="p">});</span>
</code></pre></div></div>
<p>But what is <em>p</em>? A sensible suggestion would be person as the collection is named people, but it could be pupil or even something not beginning with the letter p.</p>
<p>The lack of clarity could cause confusion to future readers of this code, it may even lead them to wrong assumptions. This is why naming is often the most important refactoring we can do to a code base, especially the removal of abbreviations that can lead to different interpretations or isomorphisms.</p>
Mon, 15 Dec 2014 19:49:51 +0000http://iainjmitchell.com/blog/isomorphism
http://iainjmitchell.com/blog/isomorphismRefactoringIntroducing Pageboy.js<p>Recently, I was explaining how to Test Drive Javascript with DOM interaction and one of the audience mentioned that they found the tests unreadable. The tests had been written in <a href="http://qunitjs.com/">qunit</a> and used <a href="http://jquery.com/">jQuery</a> to interact with the test fixture in the DOM, here is a similar example:</p>
<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nx">test</span><span class="p">(</span><span class="s1">'Hello displayed When clicking on Hello button'</span><span class="p">,</span> <span class="kd">function</span><span class="p">(){</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#hello'</span><span class="p">).</span><span class="nx">trigger</span><span class="p">(</span><span class="s1">'click'</span><span class="p">);</span>
<span class="nx">ok</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="s1">'#helloDisplay'</span><span class="p">).</span><span class="nx">is</span><span class="p">(</span><span class="s2">":visible"</span><span class="p">));</span>
<span class="p">});</span>
</code></pre></div></div>
<p>If you’ve used jQuery before, you should be able to decipher that this test is about clicking one element and checking the effect on another. But if you’re new to jQuery this maybe confusing, you’d have to investigate the framework and find out what the dollar ($) function did and the subsequent calls to trigger() and is(). Even experienced jQuery users might struggle to understand the meaning if there are multiple DOM interactions within the test.</p>
<p>So, I started to think about the possibility of creating a Domain Specific Language (DSL) to make DOM interactions in Javascript unit tests more readable. The result of this is my new open source project <strong>pageboy.js</strong>.</p>
<p>The inspiration for pageboy.js is the DSL that Capybara in Ruby uses to interact with the DOM. Capybara is a wrapper around DOM interaction that can be used in the step definitions in Cucumber BDD tests. The interactions with the DOM through the DSL are both concise and descriptive, which is what I want <strong>pageboy.js</strong> to aspire to be.</p>
<p>Once completed, the example above could be rewritten with <strong>pageboy.js</strong> as:</p>
<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nx">test</span><span class="p">(</span><span class="s1">'Hello displayed When clicking on Hello button'</span><span class="p">,</span> <span class="kd">function</span><span class="p">(){</span>
<span class="nx">clickButton</span><span class="p">(</span><span class="s1">'hello'</span><span class="p">);</span>
<span class="nx">ok</span><span class="p">(</span><span class="nx">find</span><span class="p">(</span><span class="s1">'helloDisplay'</span><span class="p">).</span><span class="nx">isVisible</span><span class="p">);</span>
<span class="p">});</span>
</code></pre></div></div>
<p>For more information or to get involved visit <strong>pageboy.js</strong> on <a href="https://github.com/iainjmitchell/pageboy.js">github</a></p>
Mon, 13 Jan 2014 11:20:00 +0000http://iainjmitchell.com/blog/pageboy
http://iainjmitchell.com/blog/pageboyJavascript,TDD8 Test Driven Development tips<p><strong>1. Have a failing test</strong> – The red stage is the first of the TDD cycle, it is complete when only one test is failing AND the test is failing on the expected assertion. Seeing the test fail is an important validation of the criteria of the test, so avoid temptation to leap into the implementation without running the tests.</p>
<p><strong>2. Simplest implementation</strong> – The objective of the second (green) stage of TDD is to implement just enough to make the failing test pass. Follow a “<strong>You Ain’t Gonna Need It</strong>” (YAGNI) approach and don’t try to second guess subsequent tests.</p>
<p><strong>3. Don’t forget to refactor!</strong> – The third stage of TDD is refactor, so after the simplest implementation deal with every <a href="http://www.dcs.gla.ac.uk/~hcp/psd/lectures/badsmells.pdf" title="Summary of common code smells">code smell</a> you can find, rather than batching up problems for later.</p>
<p><strong>4. Delete redundant tests</strong> – Sometimes we write a test to help us get somewhere, but it may become superseded by a following test. If this is the case, delete the redundant test, it no longer has any value and may cause confusion in the future.</p>
<p><strong>5. Exposing/Adding class members for testing purposes</strong> – Avoid exposing anything unnecessary on the class being tested. Typical examples of this are public flag properties introduced for easy assertions, or making a private method public to test it in isolation. Difficult to test code <em>is a sign that it needs refactoring</em>.</p>
<p><strong>6. Don’t refactor your tests</strong> – Often tests have similar setup and so it can be tempting to use a Setup method to reduce repetition. I’d avoid doing this for two reasons: 1) There is a danger that an order dependency can build up between tests, for example test 2 will only run if test 1 sets up the class correctly; 2) It can hide the pain of using the class, for example the class might have too may dependencies. Difficult to set-up code <em>is a sign that it needs refactoring</em>.</p>
<p><strong>7. Clear test names</strong> – The name of the test should mention the expected outcome and any preconditions, for example ‘IfThereIsNoFoodThenCatMeows‘. Writing the test name after writing the test is a good technique to achieve this.</p>
<p><strong>8. TDD with a friend</strong> – pairing on TDD makes it far more enjoyable, try ping pong pairing like this:</p>
<ul>
<li>Jimmy writes a failing test</li>
<li>Max make it pass in the simplest way</li>
<li>Jimmy refactors</li>
<li>Max writes a failing test… etc</li>
</ul>
Mon, 14 Oct 2013 14:00:00 +0000http://iainjmitchell.com/blog/tdd-tips
http://iainjmitchell.com/blog/tdd-tipsTDD,Refactoring8 visualisation improvements for Kanban/Scrum boards<p>A physical <a href="http://en.wikipedia.org/wiki/Kanban_(development)">Kanban</a> or <a href="http://en.wikipedia.org/wiki/Scrum_(software_development)">Scrum</a> board is usually one of the first steps that software development teams take when they set sail on an <strong>Agile</strong> course. The intention of these boards is to visualise the state of the current deliverable(s), so that all members of the team and the customer should be able to understand what is happening. This may act as a conversation starter or even help pre-empt delays in delivery.</p>
<p>Unfortunately, many boards tend to end up as messy project task boards, which hide the subtle improvements that help reduce <strong>waste</strong> and <strong>cycle time</strong>. Think about your board, would your customer really understand what is going on?</p>
<p>Here are 8 easy fixes to improve Kanban or Scrum board visualisation:</p>
<p><strong>1. Naming Avatars</strong> – Make sure that the Avatar includes the persons name, a few people in the office might know of your love of Optimus Prime, but for most it will cause confusion (unless you happen to be a robot that turns into truck).</p>
<p><strong>2. Card descriptions</strong>- Every card on the board should have a description that is concise and understandable to all members of the team. It should also be written/printed at a size that is readable from a reasonable distance, as this will aid stand-ups.</p>
<p><strong>3. Card rules</strong>- Ensure that these simple rules are adhered to:</p>
<ul>
<li>Cards in queuing columns CANNOT have Avatars on.</li>
<li>Cards in working columns MUST either have an Avatar or Blocker on, if there is no one to work on card then it is blocked.</li>
</ul>
<p><strong>4. Holding area for Avatars</strong> – Have an area of the board to place Avatars of people not actively working on a card. This can be split into areas such as holiday, illness, training and tumbleweed (no good reason). Having this will help identify when people are not contributing to delivery, which will in turn encourage tech debt and maintenance tasks to go through the board.</p>
<p><strong>5. Blocker visualisation</strong>- All blockers should contain:</p>
<ul>
<li>The <strong>reason</strong></li>
<li><strong>Who</strong> marked it blocked</li>
<li><strong>When</strong> it was blocked</li>
</ul>
<p><strong>6. Show movement</strong> – Place an arrow avatar on cards that have moved, these can then be removed after the standup. This helps to identify the cards that are NOT moving, which may reveal hidden blockers or encourage other team members to assist.</p>
<p><strong>7. Display rules/entry criteria</strong> – If you have any rules about cards being moved from column to column, such as a ‘<a href="http://www.scrumalliance.org/community/articles/2008/september/what-is-definition-of-done-(dod)">definition of done</a>‘ or review, then it can help to have these rule displayed by the relevant column on the board.</p>
<p><strong>8. Column space</strong> – Ensure that there is enough room in the columns for the card capacity. I’ve often seen situations where cards have had to be placed on top of each other, which has a obvious negative effect on visualisation.</p>
Sun, 01 Sep 2013 16:48:00 +0000http://iainjmitchell.com/blog/kanban-visualisation
http://iainjmitchell.com/blog/kanban-visualisationKanban,SCRUMFantasy world built of metrics?<p>Last weekend I went to see the <a href="http://www.bbc.co.uk/blogs/adamcurtis/posts/MASSIVE-ATTACK-V-ADAM-CURTIS">Adam Curtis and Massive Attack</a> event, which was part of the <strong>Manchester International Festival</strong>. This was an audio/visual film (or Glim – Gig integrating with a film) about the fake enchanting modern world which we live in today.</p>
<p>One of the ideas that grabbed my attention was that much of the modern world is built on numbers (or metrics), this ranges from financial planning/investments through to behaviour of political parties. The flaw in this idea is that metrics are always based upon the past actions and not the future, which leads to a future-phobic outlook and ‘safe’ decision making.</p>
<p>It was also mentioned that usage of metrics can also build up a fantasy world that bares no resemblance to reality, for example the financial metrics that allowed companies such Enron and Lehman Brothers to appear strong and competent.</p>
<p>This got me thinking about the lean/agile reliance upon metric driven development, is it possible that the more we engage in metric driven development, the more we are also entering our own fantasy world?</p>
<p>Yes and No.</p>
<p>At one of my workplaces there was an absolute obsession with <a href="http://en.wikipedia.org/wiki/Conversion_rate">Conversion Rate</a>, if it ever went down compared to the previous year then it MUST be due to something wrong in the website. So, for instance if 100 people made a purchase on the first Saturday this year then at least 100 people should be making a purchase on the first Saturday next year. Seems logical doesn’t it?</p>
<p>But what if next January is much warmer and more people decide to go out rather than buying items online? Or perhaps there is a major internet outage on the Saturday that stops all of Asia accessing your site. It’s not straightforward is it?</p>
<p>However, a great number of development teams do not use ANY metrics, decisions on new development are made by gut feel of the owner or company ‘expert’, making it impossible to measure success. This is surely a worse situation, that brings to mind a line from <a href="http://en.wikipedia.org/wiki/Brass_Eye">Brass Eye</a>:</p>
<p><em>“there’s no actual evidence for it, but it’s scientific fact”.</em></p>
<p>However, we must be careful to not let metrics stifle innovation, sometimes crazy ideas pay off (<a href="http://geesepoliceinc.com/">this company is worth over $2 million</a>).</p>
Thu, 18 Jul 2013 09:24:00 +0000http://iainjmitchell.com/blog/fantasy-world-built-of-metrics
http://iainjmitchell.com/blog/fantasy-world-built-of-metricsAgile,Kanban,Lean