<?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>On Technology and Tea « Matthew Morten</title>
	<atom:link href="http://www.mattmorten.co.uk/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mattmorten.co.uk/blog</link>
	<description>An exploration of the tech landscape</description>
	<lastBuildDate>Mon, 14 May 2012 22:53:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Painless TDD &#8211; Strip away your dependencies!</title>
		<link>http://www.mattmorten.co.uk/blog/2012/05/painless-tdd-strip-away-your-dependencies/</link>
		<comments>http://www.mattmorten.co.uk/blog/2012/05/painless-tdd-strip-away-your-dependencies/#comments</comments>
		<pubDate>Mon, 14 May 2012 22:53:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://www.mattmorten.co.uk/blog/?p=276</guid>
		<description><![CDATA[Have you ever come across the problem where, in order to construct the object you are trying to test, you end up creating massive scaffolding code just to pass to the constructor? Perhaps an example is in order: class ChessGame &#123; // Some instance variables &#160; public ChessGame &#40;Player player1, Player player2, int timeLimit&#41; &#123; [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever come across the problem where, in order to construct the object you are trying to test, you end up creating massive scaffolding code just to pass to the constructor? Perhaps an example is in order:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> ChessGame <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Some instance variables</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> ChessGame <span style="color: #009900;">&#40;</span>Player player1, Player player2, <span style="color: #000066; font-weight: bold;">int</span> timeLimit<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">player1</span> <span style="color: #339933;">=</span> player1<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">player2</span> <span style="color: #339933;">=</span> player2<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">timeLimit</span> <span style="color: #339933;">=</span> timeLimit<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> playGame<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>...<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> ChessGameTest <span style="color: #009900;">&#123;</span>
    @Test
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testChessGamePlaysForXseconds <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
        Player player1 <span style="color: #339933;">=</span> createMock<span style="color: #009900;">&#40;</span>Player.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        Player player2 <span style="color: #339933;">=</span> createMock<span style="color: #009900;">&#40;</span>Player.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        Handicap handicap1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Handicap<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span>, Rules.<span style="color: #006633;">Standard</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        Handicap handicap2 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Handicap<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">4</span>,  Rules.<span style="color: #006633;">Standard</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        expect<span style="color: #009900;">&#40;</span>player1.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">andReturn</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;D. Duck&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        expect<span style="color: #009900;">&#40;</span>player2.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">andReturn</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;M. Mouse&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        expect<span style="color: #009900;">&#40;</span>player1.<span style="color: #006633;">getHandicap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">andReturn</span><span style="color: #009900;">&#40;</span>handicap1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        expect<span style="color: #009900;">&#40;</span>player2.<span style="color: #006633;">getHandicap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">andReturn</span><span style="color: #009900;">&#40;</span>handicap2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        replayAll<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">new</span> ChessGame<span style="color: #009900;">&#40;</span>player1, player2, <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">playGame</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Assertions ....</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The problem here is that we&#8217;ve specified dependencies on far too many objects and values! By asking for two <em>Player </em>objects, you&#8217;re essentially saying &#8220;give me two objects which have names, ages, total scores, rankings, biographies, etc&#8230; and which also have very detailed Handicap information&#8221;.</p>
<p>Ask yourself this question:</p>
<ul>
<li>Without looking inside the class file, what exactly does the ChessGame need in order to execute playGame()?</li>
</ul>
<p>It&#8217;s not at all obvious is it! My guess would be that we only really need player names, and handicap information (why do we need the player bio to play a match??). If this is the case, why do we pass all that extra information to the ChessGame constructor, if it&#8217;s never going to need it?</p>
<p>I can hear you answering &#8220;But it&#8217;s far more convenient to package up that information as it exists naturally &#8211; inside the Player object. It is more readable, and keeps the number of constructor parameters down!&#8221;</p>
<p>But this is not a valid reason because of the following:</p>
<ol>
<li>Classes should not ask for more information than they need &#8211; otherwise they become difficult and cumbersome to test</li>
<li>Classes should make absolutely clear what their dependencies are. This is why passing around &#8220;Contexts&#8221; is a bad thing</li>
</ol>
<p>We can make this a lot easier by using a <em>Factory Method </em>as a convenience:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> ChessGame <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> ChessGame <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> player1Name, <span style="color: #003399;">String</span> player2Name, 
                <span style="color: #000066; font-weight: bold;">int</span> player1Handicap, <span style="color: #000066; font-weight: bold;">int</span> player2Handicap, <span style="color: #000066; font-weight: bold;">int</span> timeLimit<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">player1Name</span> <span style="color: #339933;">=</span> player1Name<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">player2Name</span> <span style="color: #339933;">=</span> player2Name<span style="color: #339933;">;</span>	
        <span style="color: #666666; font-style: italic;">//..etc</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> ChessGame withPlayers <span style="color: #009900;">&#40;</span>Player player1, Player player2, <span style="color: #000066; font-weight: bold;">int</span> timeLimit<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> ChessGame <span style="color: #009900;">&#40;</span>
            player1.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, 
            player2.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
            player1.<span style="color: #006633;">getHandicap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getAbsolute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
            player2.<span style="color: #006633;">getHandicap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getAbsolute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> playGame<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>...<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> ChessGameTest <span style="color: #009900;">&#123;</span>
    @Test
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testChessGamePlaysForXseconds <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">new</span> ChessGame<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;D. Duck&quot;</span>, <span style="color: #0000ff;">&quot;M. Mouse&quot;</span>, <span style="color: #cc66cc;">10</span>, <span style="color: #cc66cc;">4</span>, <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Assertions ....</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The second ChessGame class accepts only what it needs &#8211; it has fewer dependencies on real objects. However, we now have a nice convenience method on the object which takes our existing objects.</p>
<p>Why stop there? Here are some more Factory Methods which you might prove useful:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> ChessGame fromExistingGame <span style="color: #009900;">&#40;</span>ChessGame previousGame<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>...<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> ChessGame againstBot <span style="color: #009900;">&#40;</span>BotFactory botFactory<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>...<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> ChessGame fromDataFile <span style="color: #009900;">&#40;</span><span style="color: #003399;">File</span> dataFile<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>...<span style="color: #009900;">&#125;</span></pre></div></div>

<p>&nbsp;</p>
<p>So in conclusion &#8211; if you&#8217;re finding yourself setting up tonnes of scaffolding for a test, ask yourself whether the unit-to-be-tested is asking too much of you!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattmorten.co.uk/blog/2012/05/painless-tdd-strip-away-your-dependencies/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Painless TDD &#8211; Using Equality to Test Your Code</title>
		<link>http://www.mattmorten.co.uk/blog/2012/05/painless-tdd-using-equality-to-test-your-code/</link>
		<comments>http://www.mattmorten.co.uk/blog/2012/05/painless-tdd-using-equality-to-test-your-code/#comments</comments>
		<pubDate>Mon, 07 May 2012 13:35:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[TDD]]></category>
		<category><![CDATA[Code Smell]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JUnit]]></category>
		<category><![CDATA[Refactoring]]></category>
		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://www.mattmorten.co.uk/blog/?p=257</guid>
		<description><![CDATA[Using getter methods to assert the state of an object in during Unit Testing is brittle, and often exposes more of the object's internals than you'd like. Instead, let's try to use the .equals() method to create flexible tests which survive refactors.]]></description>
			<content:encoded><![CDATA[<p>&#8230; or, why Getters are a Code Smell!</p>
<p>A common problem arises when you need to change the underlying implementation of a class, and you want to use your existing tests to assert that the outward behaviour of this class has not changed. You may well take the following approach:</p>
<ol>
<li>Make changes to your class implementation</li>
<li>Fix any tests that have broken</li>
<li>Re-run the tests. Do they pass?</li>
</ol>
<p>Can you spot a problem with this approach? When you change your tests, you cannot rely on them to validate your code anymore. The point of verifying change using Unit Tests is that they remain an invariant. If you have changed both your code and your tests, then you have no confidence that you haven&#8217;t introduced a bug in your work!</p>
<p>Look at the code sample below:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    @Test
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testTwoCorrectAnagramsAreGenerated<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span><span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Given : a basic anagram generator</span>
        <span style="color: #666666; font-style: italic;">// When : presented with the word &quot;sleep&quot;</span>
        WordList wordList <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AnagramGenerator<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">generateAnagrams</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;sleep&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Then : we get two anagrams - &quot;sleep&quot; and &quot;peels&quot;</span>
        <span style="color: #003399;">List</span> words <span style="color: #339933;">=</span> wordList.<span style="color: #006633;">getWords</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        assertEquals<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;First anagram&quot;</span>, <span style="color: #0000ff;">&quot;sleep&quot;</span>, words.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        assertEquals<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Second anagram&quot;</span>, <span style="color: #0000ff;">&quot;peels&quot;</span>, words.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        assertEquals<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Size&quot;</span>, <span style="color: #cc66cc;">2</span>, words.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>This simple test is flawed:</p>
<ol>
<li>We are assuming that the implementation of WordList will always store its words in a <em>List&lt;String&gt;</em>. In fact, we are forced to expose the underlying structure of our object.</li>
<li>The test will fail if we change the order in which the anagrams are returned. Should the order of the returned anagrams really be a concern in this situation?</li>
<li>WordList has become a central focal point of our test, even though we are testing the <em>AnagramGenerator</em></li>
</ol>
<div></div>
<div>A better test would instead use the <em>.equals()</em> method to test correctness:</div>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    @Test
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testTwoCorrectAnagramsAreGenerated<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span><span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Given : a basic anagram generator</span>
        <span style="color: #666666; font-style: italic;">// When : presented with the word &quot;sleep&quot;</span>
        WordList list <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AnagramGenerator<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">generateAnagrams</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;sleep&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Then : we get two anagrams - &quot;sleep&quot; and &quot;peels&quot;</span>
        assertEquals<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Anagram List&quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> WordList<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;sleep&quot;</span>,<span style="color: #0000ff;">&quot;peels&quot;</span><span style="color: #009900;">&#41;</span>, list<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span></pre></div></div>

<p>The result is that we have a smaller test, which doesn&#8217;t poke around inside the WordList class when making assertions. The only thing we need to assume is that <em>Object.equals(Object)</em> has been implemented correctly (testing this can be done separately in WordListTest).</p>
<p>Furthermore, if we decide that ordering of results is not important, we can have WordList implement a HashSet. The .equals() method will therefore not check for ordering.</p>
<p>Using equality rather than introspection will ensure that your tests are less brittle and invariant to change. Happy TDDing!</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattmorten.co.uk/blog/2012/05/painless-tdd-using-equality-to-test-your-code/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Learn to Program with Poker / Code with Cards</title>
		<link>http://www.mattmorten.co.uk/blog/2011/06/learn-to-program-with-poker-code-with-cards/</link>
		<comments>http://www.mattmorten.co.uk/blog/2011/06/learn-to-program-with-poker-code-with-cards/#comments</comments>
		<pubDate>Sat, 11 Jun 2011 17:22:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Poker]]></category>

		<guid isPermaLink="false">http://www.mattmorten.co.uk/blog/2011/06/learn-to-program-with-poker-code-with-cards/</guid>
		<description><![CDATA[I love learning new programming languages. I&#8217;ve been reading Bruce Tate&#8217;s &#8220;Seven Languages In Seven Weeks&#8221; with the hope of getting a flavour of all the different paradigms on offer. It is impossible to learn a new languages by simply reading &#8211; you have to get stuck in with the code to gain a true [...]]]></description>
			<content:encoded><![CDATA[<p><img style="margin-right: 20px;" title="Cards.jpg" src="http://www.mattmorten.co.uk/blog/wp-content/uploads/2011/06/Cards.jpg" border="0" alt="P1020341" width="200" height="150" align="left" /> I love learning new programming languages. I&#8217;ve been reading <a href="http://pragprog.com/titles/btlang/seven-languages-in-seven-weeks">Bruce Tate&#8217;s &#8220;Seven Languages In Seven Weeks&#8221;</a> with the hope of getting a flavour of all the different paradigms on offer. It is impossible to learn a new languages by simply reading &#8211; you have to get stuck in with the code to gain a true understanding. Mr Tate gives us the opporutunity to dive into some practice examples he has thoughtfully prepared for us. They are a good start, but i like something more involved to move onto.</p>
<p>And that&#8217;s where poker comes in. Texas Hold&#8217;em may or may not be your cup of tea, but it is a game to perfectly test your understanding of the languages you are writing in.</p>
<p>Just look at the different elements that come into play:</p>
<ul>
<li><strong>Scoring hands.</strong> This is a non-trivial task that is on the surface, quite straightforward with OO. But scoring hands is perfect for functional languages. For extra difficulty, remember &#8211; Ace is both high and low!
</li>
<li><strong>Who wins what? </strong>With varying players in the game, and varying amounts in the pot, this could get tricky!</li>
<li><strong>Performance.</strong> Ok, so you&#8217;ve worked hard on your perfect card-scoring functions. Now we can really test how well you&#8217;ve done by asking &#8220;how many hands can we score per second?&#8221;.</li>
<li><strong>DSLs.</strong> Perhaps the language you are using is good for developing DSLs. Could you write a DSL that mimics a hand of poker? One round? Or even an entire poker game? Something such as the following would be a start (I&#8217;m pretty sure Scala&#8217;s implicit type conversions will perform this miracle):</li>
</ul>
<p style="text-align: center;">&#8220;AC QH 10S 2D 4C 8D AD&#8221; vs &#8220;3S 10C 3C 5H QD QS 7S&#8221;</p>
<ul>
<li><strong>AI. </strong>If you&#8217;ve played poker, you know it can be an infinitely complex game of deep strategy. But even a simple A.I. bot can give a player a good run for his money. Start with the basics (hand strength, pot odds, outs) and go from there.
</li>
<li><strong>Immutability. </strong>Can you complete your program whilst keeping it completely immutable? I don&#8217;t mean scores, chips, etc. I mean, can you avoid mutable data structures, state-ful functions, etc.</li>
</ul>
<p>Once I&#8217;ve written a basic poker engine once, it becomes easier to use it as a comparison between languages. I have a firmer understanding of which languages perform better in which circumstances. Oh, and it&#8217;s definitely more fun than writing business applications!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattmorten.co.uk/blog/2011/06/learn-to-program-with-poker-code-with-cards/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Get Better At: IntelliJ IDEA</title>
		<link>http://www.mattmorten.co.uk/blog/2010/12/get-better-at-intellij-idea/</link>
		<comments>http://www.mattmorten.co.uk/blog/2010/12/get-better-at-intellij-idea/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 22:14:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[Intellij]]></category>
		<category><![CDATA[Productivity]]></category>

		<guid isPermaLink="false">http://www.mattmorten.co.uk/blog/?p=223</guid>
		<description><![CDATA[IntelliJ IDEA is a wonderful piece of software. And that&#8217;s all I&#8217;m going to say; I won&#8217;t run comparisons against other popular IDEs, because that&#8217;s a subject for another day. Today, I want to talk about sharpening your skills with IDEA. Shortcuts We all know that shortcuts improve our productivity. Here are the ones I [...]]]></description>
			<content:encoded><![CDATA[<p>IntelliJ IDEA is a wonderful piece of software. </p>
<p>And that&#8217;s all I&#8217;m going to say; I won&#8217;t run comparisons against other popular IDEs, because that&#8217;s a subject for another day. Today, I want to talk about sharpening your skills with IDEA.</p>
<p><strong>Shortcuts</strong><br/><br />
We all know that shortcuts improve our productivity. Here are the ones I find most valuable:</p>
<ul>
<li><em>CTRL-W and CTRL-SHIFT-W</em>: Select progressively greater / lesser levels of code</li>
<li><em>CTRL-ALT-V</em>: Introduce Variable. See also Introduce Field / Constant</li>
<li><em>type &#8220;iter&#8221; TAB</em>: Java 5 style for loop Live Template. See sections below for more info on this</li>
<li><em>ALT-LEFT and ALT-RIGHT</em>: View previous / next tab.</li>
<li><em>CTRL-ALT-LEFT and CTRL-ALT-RIGHT</em>: Back / Forward Tab (in history).</li>
<li><em>CTRL-N and CTRL-SHIFT-N</em>: Find Class and Find File.</li>
<li><em>ALT-F12</em>: Show class outline (press again to also show Inherited members).</li>
<li><em>CTRL-D</em>: Duplicate Line.</li>
<li><em>F2 and SHIFT-F2</em>: Go to next / previous error (or warning).</li>
<li><em>ALT-INSERT</em>: Create new file popup.</li>
<li><em>CTRL-SHIFT-F</em>: Find in path.</li>
<li><em>CTRL-ALT-T</em>: Show list of Live Templates.</li>
<li><em>ALT-ENTER</em>: Show Intentions (see below for more info)</li>
</ul>
<p><strong>Live Templates</strong><br/><br />
Live Templates are snippets of code you can insert in and around pieces of code. The most common one would probably be &#8220;Surround with If&#8221;, which takes the highlighted code and surrounds it with an If statement. What&#8217;s more, it formats the code correctly so you needn&#8217;t worry about tab spacing.</p>
<p><a href="http://www.mattmorten.co.uk/blog/wp-content/uploads/2010/09/Live-Templates.gif"><img src="http://www.mattmorten.co.uk/blog/wp-content/uploads/2010/09/Live-Templates.gif" alt="" title="Live-Templates" width="441" height="427" class="aligncenter size-full wp-image-225" /></a></p>
<p>Another good Live Template is the for loop generator. Type &#8220;iter&#8221; and then hit TAB. IDEA intelligently selects a list of collections you might wish to iterate over:<br />
<a href="http://www.mattmorten.co.uk/blog/wp-content/uploads/2010/09/Iter.gif"><img src="http://www.mattmorten.co.uk/blog/wp-content/uploads/2010/09/Iter.gif" alt="" title="Iter" width="410" height="224" class="aligncenter size-full wp-image-226" /></a></p>
<p>To create you&#8217;re own templates, I would recommend you take a look at this <a href="http://blogs.jetbrains.com/idea/2006/03/defining-a-live-template-for-null-check/">Jetbrains blog post</a> describing how to create a null-check template.</p>
<p><strong>Quick Lists</strong><br />
You can create a shortcut to open a popup of commonly used items of your choosing. Within <em>Preferences</em>, go to <em>Quick Lists</em> to define a new list, and then <em>Key Intentions</em> to create a shortcut for that list. As an example:<br />
<a href="http://www.mattmorten.co.uk/blog/wp-content/uploads/2010/09/Quick-List.gif"><img src="http://www.mattmorten.co.uk/blog/wp-content/uploads/2010/09/Quick-List.gif" alt="" title="Quick-List" width="441" height="303" class="aligncenter size-full wp-image-227" /></a></p>
<p><strong>Intentions</strong><br />
Intentions can be used to perform common actions, or solve problems with your code. Hitting ALT-ENTER over a valid piece of code will give you common actions. Doing the same over an error will give some suggestions such as:</p>
<ul>
<li>Migrate Type</li>
<li>Cast expression</li>
<li>Import unknown symbol</li>
</ul>
<p>Below is an example of both forms of intention:<br />
<a href="http://www.mattmorten.co.uk/blog/wp-content/uploads/2010/09/Intentions.gif"><img src="http://www.mattmorten.co.uk/blog/wp-content/uploads/2010/09/Intentions.gif" alt="" title="Intentions" width="417" height="247" class="aligncenter size-full wp-image-232" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattmorten.co.uk/blog/2010/12/get-better-at-intellij-idea/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using WLST to find JMX MBeans on Weblogic Application Server 10.3</title>
		<link>http://www.mattmorten.co.uk/blog/2010/12/using-wlst-to-find-jmx-mbeans-on-weblogic-application-server-10-3/</link>
		<comments>http://www.mattmorten.co.uk/blog/2010/12/using-wlst-to-find-jmx-mbeans-on-weblogic-application-server-10-3/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 22:12:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[JMX]]></category>
		<category><![CDATA[Weblogic]]></category>

		<guid isPermaLink="false">http://www.mattmorten.co.uk/blog/?p=184</guid>
		<description><![CDATA[I was recently asked to retrieve a selection of JMX MBean attribute values from Weblogic Application Server, and format the data as XML to be read by Nagios. JBoss Application Server provides a nice frontend within their administration console in which to naviate the MBean hierarchy, and find the MBean names you need. Oracle doesn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently asked to retrieve a selection of JMX MBean attribute values from Weblogic Application Server, and format the data as XML to be read by <a href="http://www.nagios.org/">Nagios</a>. JBoss Application Server provides a nice frontend within their administration console in which to naviate the MBean hierarchy, and find the MBean names you need.</p>
<p>Oracle doesn&#8217;t do this when it comes to Weblogic 10.3. Instead, you can either use educated guesswork in combination with some <a href="http://download.oracle.com/docs/cd/E15051_01/wls/docs103/wlsmbeanref/core/index.html">useful documentation</a>. Or you can use <a href="http://download-llnw.oracle.com/docs/cd/E12840_01/wls/docs103/config_scripting/using_WLST.html">WLST</a> &#8211; the Weblogic Scripting Tool.</p>
<p><strong>Using the Weblogic Scripting Tool</strong><br />
The first thing to do is find the binary. This is located here:</p>
<p><code>%BEA_HOME%/common/bin/wlst.bat     &lt;-- Windows<br />
%BEA_HOME%/common/bin/wlst.sh       &lt;-- Unix</code></p>
<p>Start the executable, and wait until you receive a prompt. There is a list of <a href="http://download.oracle.com/docs/cd/E13222_01/wls/docs90/config_scripting/reference.html">common commands</a> you will need:</p>
<p><code><br />
connect('username','password','host:port')<br />
serverRuntime()<br />
cd('beanName')<br />
ls()  </code></p>
<p>As you can see, you will be familiar with the commands if you have ever used a unix command prompt before. Be aware that we execure the commands like functions, within brackets, with a number of arguments.</p>
<p><strong>Example</strong><br />
<code><br />
Welcome to WebLogic Server Administration Scripting Shell</p>
<p>Type help() for help on available commands</p>
<p>wls:/offline> connect('weblogic','weblogic','localhost:7001')<br />
Connecting to t3://localhost:7001 with userid weblogic ...<br />
Successfully connected to Admin Server 'devserver' that belongs to domain 'vfdomain'.</p>
<p>Warning: An insecure protocol was used to connect to the<br />
server. To ensure on-the-wire security, the SSL port or<br />
Admin port should be used instead.</p>
<p>wls:/vfdomain/serverConfig> serverRuntime()<br />
Location changed to serverRuntime tree. This is a read-only tree with ServerRuntimeMBean as the root.<br />
For more help, use help(serverRuntime)</p>
<p>wls:/vfdomain/serverRuntime> ls()<br />
dr--   ApplicationRuntimes<br />
dr--   AsyncReplicationRuntime<br />
dr--   ClusterRuntime<br />
dr--   ConnectorServiceRuntime<br />
dr--   DefaultExecuteQueueRuntime<br />
dr--   EntityCacheCumulativeRuntime<br />
dr--   EntityCacheCurrentStateRuntime<br />
dr--   EntityCacheHistoricalRuntime<br />
dr--   ExecuteQueueRuntimes<br />
dr--   JDBCServiceRuntime<br />
dr--   JMSRuntime<br />
dr--   JTARuntime</p>
<p>snip....<br />
-r--   ActivationTime                               1267615098514<br />
-r--   AdminServer                                  true<br />
-r--   AdminServerHost                              127.0.0.1<br />
-r--   AdminServerListenPort                        7001<br />
-r--   AdminServerListenPortSecure                  false<br />
-r--   AdministrationPort                           9002<br />
snip....<br />
</code></p>
<p>The first list of items are <strong>child MBeans</strong>. The second list are <strong>attributes</strong>.</p>
<p>We can navigate to our JDBC connections like so:</p>
<p><code><br />
wls:/vfdomain/serverRuntime> cd('JDBCServiceRuntime/myserver/JDBCDataSourceRuntimeMBeans/mydatasource')<br />
wls:/vfdomain/serverRuntime/DBCServiceRuntime/myserver/JDBCDataSourceRuntimeMBeans/mydatasource> ls()<br />
snip...<br />
-r--   ConnectionDelayTime                          97<br />
-r--   ConnectionsTotalCount                        144<br />
-r--   CurrCapacity                                 10<br />
-r--   CurrCapacityHighCount                        11<br />
-r--   DeploymentState                              2<br />
-r--   Enabled                                      true<br />
-r--   FailedReserveRequestCount                    0<br />
-r--   FailuresToReconnectCount                     0<br />
-r--   HighestNumAvailable                          12<br />
-r--   HighestNumUnavailable                        0<br />
-r--   LastTask                                     null<br />
-r--   LeakedConnectionCount                        0<br />
-r--   ModuleId                                     mydatasource<br />
-r--   Name                                         mydatasource<br />
-r--   NumAvailable                                 10<br />
-r--   NumUnavailable                               0<br />
-r--   PrepStmtCacheAccessCount                     7836<br />
-r--   PrepStmtCacheAddCount                        3808<br />
-r--   PrepStmtCacheCurrentSize                     99<br />
snip...<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattmorten.co.uk/blog/2010/12/using-wlst-to-find-jmx-mbeans-on-weblogic-application-server-10-3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>You&#8217;re still Beautiful!</title>
		<link>http://www.mattmorten.co.uk/blog/2010/09/youre-still-beautiful/</link>
		<comments>http://www.mattmorten.co.uk/blog/2010/09/youre-still-beautiful/#comments</comments>
		<pubDate>Sun, 05 Sep 2010 15:39:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[iPod Apple 1st-gen]]></category>

		<guid isPermaLink="false">http://www.mattmorten.co.uk/blog/?p=214</guid>
		<description><![CDATA[Dug out my old first-gen iPod today. It really is a wonderful piece of kit, and at nearly 9 years old you&#8217;ve got to praise the Apple designers for putting so much work into it. Next job &#8211; Firewire cable!]]></description>
			<content:encoded><![CDATA[<p>Dug out my old first-gen iPod today. It really is a wonderful piece of kit, and at nearly 9 years old you&#8217;ve got to praise the Apple designers for putting so much work into it.</p>
<p>Next job &#8211; Firewire cable!</p>
<table style="margin-left:auto;margin-right:auto">
<tr>
<td><a href="http://www.mattmorten.co.uk/blog/wp-content/uploads/2010/09/P1020095.jpg"><img class="aligncenter size-thumbnail wp-image-217" title="You're still beautiful" src="http://www.mattmorten.co.uk/blog/wp-content/uploads/2010/09/P1020095-150x150.jpg" alt="" width="150" height="150" /></a>
</td>
<td><a href="http://www.mattmorten.co.uk/blog/wp-content/uploads/2010/09/P1020099.jpg"><img class="aligncenter size-thumbnail wp-image-216" title="Look, Firewire!" src="http://www.mattmorten.co.uk/blog/wp-content/uploads/2010/09/P1020099-150x150.jpg" alt="" width="150" height="150" /></a></td>
<td><a href="http://www.mattmorten.co.uk/blog/wp-content/uploads/2010/09/P1020100.jpg"><img class="aligncenter size-thumbnail wp-image-215" title="Now and Then" src="http://www.mattmorten.co.uk/blog/wp-content/uploads/2010/09/P1020100-150x150.jpg" alt="" width="150" height="150" /></a></td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.mattmorten.co.uk/blog/2010/09/youre-still-beautiful/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DIY Flash Bounce for Panasonic GF1</title>
		<link>http://www.mattmorten.co.uk/blog/2010/04/diy-flash-bounce-for-panasonic-gf1/</link>
		<comments>http://www.mattmorten.co.uk/blog/2010/04/diy-flash-bounce-for-panasonic-gf1/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 19:03:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[DIY]]></category>
		<category><![CDATA[Lighting]]></category>
		<category><![CDATA[Panasonic GF1]]></category>
		<category><![CDATA[Photography]]></category>

		<guid isPermaLink="false">http://www.mattmorten.co.uk/blog/?p=198</guid>
		<description><![CDATA[A Panasonic GF1, some white card, scissors, and 60 seconds. Now you have a fantastically simple bounce-flash to use in low light conditions, to achieve natural skin tones and background detail.]]></description>
			<content:encoded><![CDATA[<p>As of this weekend, I am now a proud owner of a <a href="http://www.dpreview.com/reviews/PanasonicGF1/">Panasonic GF1 + 20mm pancake lens</a>. So far I&#8217;m extremely impressed &#8211; the 1.7 aperture allows me to take some great indoor shots without the need to use any flash.</p>
<p>Like most DSLRs the in-built flash leaves a lot to be desired, so I try to use it as little as possible. There are times however, when I just can&#8217;t get away without shooting with it. I don&#8217;t want to purchase an external flash unit because for me that would detract from the very reason for purchasing a Micro Four Thirds camera in the first place &#8211; portability.</p>
<p>Then I stumbled upon the <a href="http://www.diyphotography.net/the-party-bouncer-is-back-in-business">following solution</a> from DIYPhotography.com. The plan is simple &#8211; wedge a small piece of white card into the opening of the flash, so it is angled 45 degrees to the flash pointing upwards. The card should extend the width of the flash unit, and preferably just beyond the top, like so:</p>
<p><a href="http://www.mattmorten.co.uk/blog/wp-content/uploads/2010/04/Flash-Card.jpg"><img class="aligncenter size-medium wp-image-200" title="Flash-Card" src="http://www.mattmorten.co.uk/blog/wp-content/uploads/2010/04/Flash-Card-300x292.jpg" alt="" width="300" height="292" /></a></p>
<p>Simple &#8211; a 2 minute job!</p>
<p>I took a couple of test shots &#8211; all with the same shutter speed / ISO / aperture. I took them indoors in low light, where the default exposure would have failed to produce acceptable photographs. I haven&#8217;t adjusted the images in any way. Here are the results:</p>
<p><a href="http://www.mattmorten.co.uk/blog/wp-content/uploads/2010/04/Bounce-Flash.jpg"><img class="aligncenter size-large wp-image-201" title="Bounce-Flash" src="http://www.mattmorten.co.uk/blog/wp-content/uploads/2010/04/Bounce-Flash-1024x441.jpg" alt="" width="800" height="304" /></a>The results are pretty conclusive. I would never have been able to shoot at ISO 100 indoors in low light, particularly at 1/80 without a flash. Now I can get realistic skin tones, background detail, and no more &#8220;rabbit in the headlights&#8221; look. You might get some funny looks, but you&#8217;ll appreciate those superior photos.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattmorten.co.uk/blog/2010/04/diy-flash-bounce-for-panasonic-gf1/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Groovy Jobs Mashup &#8211; Buzzwords Search</title>
		<link>http://www.mattmorten.co.uk/blog/2009/12/groovy-jobs-mashup-buzzwords-search/</link>
		<comments>http://www.mattmorten.co.uk/blog/2009/12/groovy-jobs-mashup-buzzwords-search/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 15:41:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Collective Intelligence]]></category>
		<category><![CDATA[Groovy]]></category>

		<guid isPermaLink="false">http://www.mattmorten.co.uk/blog/?p=132</guid>
		<description><![CDATA[Automatically scan online job postings for keywords commonly related to certain job titles. In this example, we see what skills are commonly required of a &#8220;Web Developer&#8221; I&#8217;ve been playing with Groovy and HTTPBuilder lately, using them to get JSON from open web services to use in mashups. I also started thinking about jobs (to [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Automatically scan online job postings for keywords commonly related to certain job titles. In this example, we see what skills are commonly required of a &#8220;Web Developer&#8221;</p></blockquote>
<p>I&#8217;ve been playing with <a href="http://groovy.codehaus.org/">Groovy</a> and <a href="http://groovy.codehaus.org/modules/http-builder/">HTTPBuilder</a> lately, using them to get <a href="http://www.json.org/">JSON</a> from open web services to use in mashups.</p>
<p>I also started thinking about jobs (to my current employer &#8211; no, I&#8217;m not looking for a new one). Wouldn&#8217;t it be useful to know what skills are being demanded in the current job market. For example, being a Java developer at heart, should I be learning Ant or Maven? What about EJB3 or Spring? How about .NET &#8211; do many jobs ask for both?</p>
<p>Below, I&#8217;ve written a simple Groovy script to get job postings off the job site <a href="http://www.authenticjobs.com">AuthenticJobs.com</a> (simply because they had an public API with no hurdles to jump).  With those postings, the program will search the job description for keywords, and see which ones come out on top. This is by no means scientific, but it could make a useful tool for anyone in the job market, especially a newcomer such as a Graduate. </p>
<p>First, we must set up a new HTTP request:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">groovyx.net.http.HTTPBuilder</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">static</span> groovyx.<span style="color: #006600;">net</span>.<span style="color: #006600;">http</span>.<span style="color: #aaaadd; font-weight: bold;">Method</span>.<span style="color: #006600;">GET</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">static</span> groovyx.<span style="color: #006600;">net</span>.<span style="color: #006600;">http</span>.<span style="color: #006600;">ContentType</span>.<span style="color: #006600;">TEXT</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">net.sf.json.groovy.*</span>
&nbsp;
@Grab<span style="color: #66cc66;">&#40;</span>group<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'org.codehaus.groovy.modules.http-builder'</span>, module<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'http-builder'</span>,
   version<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'0.5.0-RC2'</span><span style="color: #66cc66;">&#41;</span>
@Grab<span style="color: #66cc66;">&#40;</span>group<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'net.sf.json-lib'</span>, module<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'json-lib'</span>, version<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'2.3'</span>, 
   classifier<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'jdk15'</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">def</span> http <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HTTPBuilder<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'http://www.authenticjobs.com'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></pre></div></div>

<p>Notice the use of the Grab annotation. This is a nice feature within Groovy called <a href="http://groovy.codehaus.org/Grape">Grape</a>, which connects to the internet and downloads all the dependencies for the project. In this case, we need a JSON library, and the HTTPBuilder library.</p>
<p>Now we will issue an HTTP request to the AuthenticJobs webservice. We will ask for a list of fifteen matches, with keywords &#8220;Web Developer&#8221;, in JSON format:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">def</span> data <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">;</span>
&nbsp;
http.<span style="color: #006600;">request</span><span style="color: #66cc66;">&#40;</span>GET,TEXT<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    uri.<span style="color: #006600;">path</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'/api/'</span>
    uri.<span style="color: #006600;">query</span> <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>api_key:<span style="color: #ff0000;">&quot;++++hidden++++&quot;</span>,
                  method: <span style="color: #ff0000;">&quot;aj.jobs.search&quot;</span>,
                  keywords: <span style="color: #ff0000;">&quot;web developer&quot;</span>,
                  perpage: <span style="color: #ff0000;">&quot;15&quot;</span>,
                  format:<span style="color: #ff0000;">&quot;json&quot;</span><span style="color: #66cc66;">&#93;</span>
&nbsp;
    response.<span style="color: #006600;">success</span> <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>resp,unformatted <span style="color: #66cc66;">-&gt;</span>
       data <span style="color: #66cc66;">=</span> unformatted.<span style="color: #006600;">text</span><span style="color: #66cc66;">;</span>
    <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Now lets parse the data into JSON format so we can extract the job descriptions:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">def</span> json <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JsonSlurper<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">parseText</span><span style="color: #66cc66;">&#40;</span>data<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Let&#8217;s define some variables which we will use when processing the JSON. You will see that we are doing a match on list items (bullet points). It&#8217;s not unfair to reason that most of the &#8220;skills&#8221; we wish to extract will be mentioned in bullet-pointed lists.</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">def</span> words <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>:<span style="color: #66cc66;">&#93;</span>      <span style="color: #808080; font-style: italic;">// This is where we store the keywords</span>
<span style="color: #000000; font-weight: bold;">def</span> match <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;&lt;li&gt;([^&lt;]+)&lt;/li&gt;&quot;</span>             <span style="color: #808080; font-style: italic;">// Where to look within the description</span>
<span style="color: #000000; font-weight: bold;">def</span> filter <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;and&quot;</span>,<span style="color: #ff0000;">&quot;to&quot;</span>,<span style="color: #ff0000;">&quot;in&quot;</span>,<span style="color: #ff0000;">&quot;of&quot;</span>,             <span style="color: #808080; font-style: italic;">// Common words to remove</span>
                  <span style="color: #ff0000;">&quot;a&quot;</span>,<span style="color: #ff0000;">&quot;with&quot;</span>,<span style="color: #ff0000;">&quot;the&quot;</span>,<span style="color: #ff0000;">&quot;one&quot;</span>,
                  <span style="color: #ff0000;">&quot;at&quot;</span>,<span style="color: #ff0000;">&quot;it&quot;</span>,<span style="color: #ff0000;">&quot;for&quot;</span>,<span style="color: #ff0000;">&quot;as&quot;</span>,<span style="color: #ff0000;">&quot;on&quot;</span>,
                   <span style="color: #ff0000;">&quot;be&quot;</span>, <span style="color: #ff0000;">&quot;or&quot;</span>, <span style="color: #ff0000;">&quot;is&quot;</span><span style="color: #66cc66;">&#93;</span> 
<span style="color: #000000; font-weight: bold;">def</span> junk <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;,&quot;</span>,<span style="color: #ff0000;">&quot;—&quot;</span>,<span style="color: #ff0000;">&quot;.&quot;</span><span style="color: #66cc66;">&#93;</span>                           <span style="color: #808080; font-style: italic;">// Some junk to filter out</span></pre></div></div>

<p>Finally, the processing below:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;">json.<span style="color: #006600;">listings</span>.<span style="color: #006600;">listing</span>.<span style="color: #663399;">each</span> <span style="color: #66cc66;">&#123;</span>
  job <span style="color: #66cc66;">-&gt;</span> job.<span style="color: #006600;">description</span>.<span style="color: #006600;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">split</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #663399;">findAll</span> <span style="color: #66cc66;">&#123;</span>it <span style="color: #66cc66;">=</span>~ match<span style="color: #66cc66;">&#125;</span>.<span style="color: #663399;">each</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">def</span> matcher <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#40;</span>it <span style="color: #66cc66;">=</span>~ match<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>                            <span style="color: #808080; font-style: italic;">// Find all bullet points</span>
    <span style="color: #aaaadd; font-weight: bold;">String</span> allWords <span style="color: #66cc66;">=</span> matcher<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">;</span>
    junk.<span style="color: #663399;">each</span> <span style="color: #66cc66;">&#123;</span>allWords <span style="color: #66cc66;">=</span> allWords.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span>it,<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>    <span style="color: #808080; font-style: italic;">// Remove junk chars</span>
    allWords.<span style="color: #006600;">split</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #663399;">each</span> <span style="color: #66cc66;">&#123;</span>                                       <span style="color: #808080; font-style: italic;">// Split into individual words</span>
        word <span style="color: #66cc66;">-&gt;</span> words<span style="color: #66cc66;">&#91;</span>word<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> 
                 <span style="color: #66cc66;">&#40;</span>words<span style="color: #66cc66;">&#91;</span>word<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">==</span> <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">?</span>  <span style="color: #cc66cc;">1</span> : words<span style="color: #66cc66;">&#91;</span>word<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">+</span> <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
filter.<span style="color: #663399;">each</span> <span style="color: #66cc66;">&#123;</span>words.<span style="color: #006600;">remove</span> <span style="color: #66cc66;">&#40;</span>it<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>                               <span style="color: #808080; font-style: italic;">// Take out common words</span>
words.<span style="color: #663399;">sort</span> <span style="color: #66cc66;">&#123;</span>a, b <span style="color: #66cc66;">-&gt;</span> b.<span style="color: #006600;">value</span> <span style="color: #66cc66;">&lt;=&gt;</span> a.<span style="color: #006600;">value</span><span style="color: #66cc66;">&#125;</span>.<span style="color: #663399;">each</span> <span style="color: #66cc66;">&#123;</span>       
    k,v <span style="color: #66cc66;">-&gt;</span> <span style="color: #993399;">print</span> <span style="color: #ff0000;">&quot; (${k}, ${v}) &quot;</span>                                 <span style="color: #808080; font-style: italic;">// Sort in descending order of relevence</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Here is my output from running the above for the string &#8220;Web Developer&#8221;:</p>
<blockquote><p>(experience, 28)  (web, 14)  (knowledge, 12)  (javascript, 11)  (design, 11)<br />
(development, 10)  (css, 8)  (must, 8)  (strong, 7)  (media, 7)  (have, 7)<br />
(working, 7)  (php, 6)  (skills, 6)  (ability, 6)  (using, 6)  (sites, 6)<br />
(html, 5) (understanding, 5)  (xhtml, 4)  (familiarity, 4)  (other, 4)<br />
(interaction, 4)  ((we, 4)  (this, 4)  (has, 4)  (user, 4)  (work, 4)<br />
(use, 4)  (accessibility, 3)  (seo, 3)  (plus, 3)  (communication, 3)<br />
(new, 3)  (technologies, 3)  (creative, 3)  (clean, 3)  (email, 3)<br />
(interface, 3)  (jquery, 3)  (creating, 3)  (website, 3)  (their, 3)<br />
(building, 3)  (photoshop, 3)  (cross-browser, 3)  (ajax, 3)<br />
(excellent, 3)  (able, 3)  (programming, 3)  (please, 3)  (will, 3)<br />
(front-end, 2)  (development;, 2)  (least, 2)  (tools, 2)<br />
(adobe, 2)  (fluency, 2)  (best, 2)  (practices, 2)  (visual, 2)  (verbal, 2)<br />
(interpersonal, 2)  (desire, 2)  (learn, 2)  (projects, 2)<br />
(code, 2)  (wordpress, 2)</p></blockquote>
<p>Let&#8217;s analyse some of what we have found above:</p>
<ul>
<li>Clear skill requirements are Javascript, CSS, PHP, XTML</li>
<li>It is good to see that the industry rates accessibility as must-have</li>
<li>This could be a tenuous observation, but experience comes well above both skills and ability combined</li>
<li>Soft-skills have found their way onto the list as much as hard-skills. Indeed the days of pure computer geek-ery are over</li>
</ul>
<p>Once again I want to point out the unscientific nature of this experiment.</p>
<p>AuthenticJobs ask users of their API to limit the number of requests to something reasonable, so caching would probably be a good strategy to use here, though I have left it out for brevity. I invite people to take what I have written here and use as they see fit.</p>
<p>Hope you find it useful!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattmorten.co.uk/blog/2009/12/groovy-jobs-mashup-buzzwords-search/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Introduction to Neural Networks Part 1 : Concepts</title>
		<link>http://www.mattmorten.co.uk/blog/2009/12/introduction-to-neural-networks-part-1-concepts/</link>
		<comments>http://www.mattmorten.co.uk/blog/2009/12/introduction-to-neural-networks-part-1-concepts/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 00:29:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Neural Networks]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[Groovy]]></category>

		<guid isPermaLink="false">http://www.mattmorten.co.uk/blog/?p=46</guid>
		<description><![CDATA[Neural networks might sounds complicated and abstract (and indeed they can be), but they can also be very useful in solving a wide variety of problems, from product recommendation to facial recognition. This series will introduce the absolute basics behind this fascinating subject.]]></description>
			<content:encoded><![CDATA[<p>Neural networks might sound complicated and abstract (and indeed they can be), but they can also be very useful in solving a wide variety of problems in the field of <a href="http://en.wikipedia.org/wiki/Artificial_intelligence">Artificial Intelligence</a> and <a href="http://ai.stanford.edu/~nilsson/mlbook.html">Machine Learning</a>, such as product recommendation and categorization. Lets not be mistaken, these areas can be <em>very</em> big business, as demonstrated with the <a title="Netflix Prize" href="http://www.netflixprize.com/">Netflix Prize</a>. Whilst these simple examples may not have been able to net you the $1million prize, this series will introduce some of the basics behind this fascinating subject, and give you some code to start programming with.</p>
<p>Before we start, I want to give a very quick definition of a <a href="http://en.wikipedia.org/wiki/Artificial_neural_network">Neural Network</a>. It is far from being accurate and all-encompassing, but it will give you enough to get you through this tutorial. For now, this is what you need to know:</p>
<blockquote><p>A Neural Network is a &#8220;machine&#8221; which takes an input and approximates a desired output, based on what it has been &#8220;trained&#8221; to do.</p></blockquote>
<p><strong>Symbol Processors and Elementary Mathematics</strong></p>
<p>When we were first taught about basic functions in Maths class, we were asked to think of them like a &#8220;machine&#8221; or a &#8220;black box&#8221;. You feed a number into this box, and receive a different number out, depending on what the function was supposed to do. For example, a function named &#8220;Plus 2&#8243; would take any input and return that input + 2.</p>
<p style="text-align: center;">
<div id="attachment_65" class="wp-caption aligncenter" style="width: 303px"><img class="size-full wp-image-65 " title="Neural-Networks-1---Functions" src="http://www.mattmorten.co.uk/blog/wp-content/uploads/2009/12/Neural-Networks-1-Functions.gif" alt="A simple &quot;function&quot; as taught in elementry Maths classes. Notice the function being approximated is static and hard-coded" width="293" height="78" /><p class="wp-caption-text">A simple &quot;function&quot; as taught in elementary Maths classes. Notice the function being approximated is static and hard-coded</p></div>
<p>This is what we&#8217;ve all implicitly known as a Symbol Processor. Feed in symbol, operate on it, receive a new symbol.</p>
<p>Not too far down the road we were shown more complex examples, such as <a title="Wikipedia - Non Linear Systems" href="http://en.wikipedia.org/wiki/Nonlinear_system">non-linear functions</a>. Using a suitably complex non-linear function, you could get your &#8220;machine&#8221; to return any output you see fit. We were also shown functions that had more than one input:</p>
<div id="attachment_73" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-73" title="Neural-Networks-1---Complex" src="http://www.mattmorten.co.uk/blog/wp-content/uploads/2009/12/Neural-Networks-1-Complex-300x97.gif" alt="Same again, but non-linear and multiple inputs" width="300" height="97" /><p class="wp-caption-text">Same again, but non-linear and multiple inputs</p></div>
<p>On a side note, this is how the preceding function might be written in <a href="http://groovy.codehaus.org/">Groovy</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">8</span><span style="color: #66cc66;">&#93;</span>,<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">7</span><span style="color: #66cc66;">&#93;</span>,<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">3</span>,<span style="color: #cc66cc;">6</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #663399;">collect</span> <span style="color: #66cc66;">&#123;</span> it<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">**-</span><span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">+</span> <span style="color: #aaaadd; font-weight: bold;">Math</span>.<span style="color: #006600;">E</span><span style="color: #66cc66;">**</span>it<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">;</span></pre></div></div>

<p><strong>Learning through doing</strong></p>
<p>But what if we want do describe a particular function for which we do not have an equation, but instead a set of example data. E.g. we know what output values we want to receive from a particular set of inputs, and would like the function to approximate this (and fill in the gaps as best it can).</p>
<p>This is where Neural Networks come into play. Think of one of these as a <em>moldable</em> function, which we shape by through <em>training</em>.</p>
<p>For example, lets pretend we wanted to create a function which simulated the thought processes of a pet Gorilla. It takes inputs in the form of thoughts and ideas, and returns what it thinks is acceptable behavior:
<table id="wp-table-reloaded-id-1-no-1" class="wp-table-reloaded wp-table-reloaded-id-1">
<thead>
	<tr class="row-1 odd">
		<th class="column-1">Contept(s)</th><th class="column-2">Rating</th>
	</tr>
</thead>
<tbody>
	<tr class="row-2 even">
		<td class="column-1">People</td><td class="column-2">Good</td>
	</tr>
	<tr class="row-3 odd">
		<td class="column-1">Eating</td><td class="column-2">Good</td>
	</tr>
	<tr class="row-4 even">
		<td class="column-1">Eating, People</td><td class="column-2">Bad</td>
	</tr>
	<tr class="row-5 odd">
		<td class="column-1">Eating, Food</td><td class="column-2">Good</td>
	</tr>
	<tr class="row-6 even">
		<td class="column-1">Talk</td><td class="column-2">Good (I'm an excellent monkey-trainer!)</td>
	</tr>
	<tr class="row-7 odd">
		<td class="column-1">Talk, [to] People</td><td class="column-2">Good</td>
	</tr>
	<tr class="row-8 even">
		<td class="column-1">Talk, [to] Food</td><td class="column-2">Bad</td>
	</tr>
	<tr class="row-9 odd">
		<td class="column-1">Talk, [to] People, [whilst] Eating</td><td class="column-2">Bad (Very bad manners)</td>
	</tr>
	<tr class="row-10 even">
		<td class="column-1">Talk, [to] Food, [in front of] People</td><td class="column-2">Disaster!</td>
	</tr>
</tbody>
</table>
</p>
<p>This big mess would require quite some algebraic function to replicate! How would that even look like if we were to build that function in Mathematics? We could on the other hand use a lookup table to model this, but then any in-between state would be ambiguous &#8211; life is never black and white.</p>
<p>The astute amongst you might have noticed the clue within the title. Neural Networks are how the the living brain performs computation, and <a href="http://en.wikipedia.org/wiki/Artificial_neural_network">Artificial Neural Networks</a> (ANNs) are our way of harnessing that technique and for computational purposes.</p>
<p>Similarly, our brains were given a <em>training set </em>- a set of rules which we had to learn similar to the above &#8211; there was never any mathematics involved.</p>
<p><strong>Inside the Box</strong></p>
<p>So what <em>is </em>an ANN? Well, what it looks like does depend on what you want it to do (indeed, not all parts of the brain look the same, so why can&#8217;t we cheat as well?). Generally speaking, an ANN contains <em>neurons </em>and <em>synapses </em>(just like a human brain) &#8211; each synapse linking two neurons together at either end. As with normal brain activity, a &#8220;charge&#8221; is passed from neuron to neuron via these synapses. The degree to which this transmission occurs is specified by the <em>weight</em> of the synapse, ie, a synapse with weight w=0.0 will transfer no charge, similarly if w=1.0 all of the charge is transmitted.</p>
<p>The human brain contains <a title="Number of Neurons in the Human Brain" href="http://hypertextbook.com/facts/2002/AniciaNdabahaliye2.shtml">millions</a> of such networks (or one big network if you think of it like that), but when using ANNs we can simplify to just a handful:</p>
<div id="attachment_111" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-111" title="Neural-Networks-1---MLP" src="http://www.mattmorten.co.uk/blog/wp-content/uploads/2009/12/Neural-Networks-1-MLP-300x225.gif" alt="A small Artificial Neural Network" width="300" height="225" /><p class="wp-caption-text">A small Artificial Neural Network</p></div>
<p>The network above is what is known as a Multi Layer Perceptron, and consists of at least 3 layers:</p>
<ul>
<li>An input layer which represents the inputs to the function</li>
<li>An output layer which represents the outputs of the function</li>
<li>One or more hidden layers which encodes the complexity</li>
</ul>
<p>Using a suitably complex network, which has previously been exposed to appropriate training data (to be explored in Part 2), the following sequence takes place:</p>
<ul>
<li>We decide what the network represents. For the network shown above, we may wish to say that the 1st input means &#8220;Eat&#8221; and the 2nd means &#8220;People&#8221;. The output would mean &#8220;Good&#8221; or &#8220;Bad&#8221;</li>
<li>We show our inputs to the input layer. This is in the form of a number between 0 and 1. For example, inputting a charge of  [1 , 0] would mean &#8220;Eat&#8221; &#8220;Not People&#8221;</li>
<li>The charge from these neurons are propagated to the next layer, depending on the weight of each individual synapse. This is where the magic happens.</li>
<li>The hidden neurons pass on their signals to the output layer, once again based on the weight of each connecting synapse.</li>
<li>The signal reaches the output layer, where we can extract our result.</li>
</ul>
<div id="attachment_119" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-119 " title="Neural-Networks-1---MLP-Stim" src="http://www.mattmorten.co.uk/blog/wp-content/uploads/2009/12/Neural-Networks-1-MLP-Stim-300x225.gif" alt="The yellow neurons show how much charge they have" width="300" height="225" /><p class="wp-caption-text">&quot;Charged&quot; neurons, shown glowing in yellow</p></div>
<p>The key thing to keep in mind here is that what you get out of the network is <em><strong>entirely</strong></em> dependent on the weights of the individual synapses, different combinations of which can produce entirely different outcomes. <em>In effect, the knowledge the network stores IS the network itself.</em> Complexity increases with the number of neurons and synapses, so the larger the network, the more patterns we can approximate.</p>
<p><strong>Training</strong></p>
<p>Because the weights of the synapses in an ANN are randomized at first, the network will most likely produce entirely the wrong result. To combat this, we <em>train </em>the network. When showing inputs to the network and observing an output, we decide how close this is to our <em>desired output. </em>For example, if we stimulate &#8220;Eat, People&#8221; and the network returns &#8220;Good&#8221;, then we tinker with the weights in the network ever so slightly in order to get closer to the desired outcome. Just like training a real gorilla, after many repetitions &#8220;Show, Observe, Adjust Behavior&#8221; the network learns the data.</p>
<p><strong>And this relates to the real-world&#8230;.how?</strong></p>
<p>Simple, for example you can quite quickly build a function which outputs a list of films your customers might like to rent, based on ones they have already rented. All you have to do is get data in the form &#8220;She rented film X, then rented film Y&#8221;, continually show it to the network, and sit back and watch it learn (OK, it might not be <em>that </em>simple, but my point stands).</p>
<p>And talking of Netflix, we&#8217;ve arrived back at the start.</p>
<p><strong>That&#8217;s where I will leave you for today. In Part 2, I will examine more closely how these networks operate, and the mathematics behind them. In Part 3, we will be programming a basic Multilayer Perceptron in Groovy. Part 4 will finally discuss some alternatives to MLPs and their uses.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattmorten.co.uk/blog/2009/12/introduction-to-neural-networks-part-1-concepts/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Build new Business, Protect existing Revenue</title>
		<link>http://www.mattmorten.co.uk/blog/2009/12/build-new-business-protect-existing-revenue/</link>
		<comments>http://www.mattmorten.co.uk/blog/2009/12/build-new-business-protect-existing-revenue/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 14:03:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://www.mattmorten.co.uk/blog/?p=33</guid>
		<description><![CDATA[When working for one of my former employers, one of the core catchphrases we would hear over and over again would be: Build new business, Protect existing revenue It&#8217;s a simple mantra, fairly straightforward and generally good advice. The issue arises when these two aims are diametricly opposed. Take Microsoft for example. They risk taking [...]]]></description>
			<content:encoded><![CDATA[<p>When working for one of my former employers, one of the core catchphrases we would hear over and over again would be:</p>
<blockquote><p>Build new business, Protect existing revenue</p></blockquote>
<p>It&#8217;s a simple mantra, fairly straightforward and generally good advice.</p>
<p>The issue arises when these two aims are diametricly opposed. Take Microsoft for example. They risk taking business away from their existing &#8220;offline&#8221; products such as Office, Windows and Visual Studio with cloud-based alternatives. The decision they have to make is clear, but implementation is painful.</p>
<p>For a company like Google, the process is far simpler &#8211; they have no existing profit streams to subtract from by introducing <a href="http://docs.google.com">Google Docs</a>, <a href="http://googleblog.blogspot.com/2009/07/introducing-google-chrome-os.html">Chrome OS</a> etc. Perhaps this is why Google appear to have a far brighter future than Microsoft for the time being.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattmorten.co.uk/blog/2009/12/build-new-business-protect-existing-revenue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
