<?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>Hull Digital &#187; development</title>
	<atom:link href="http://hulldigital.co.uk/tag/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://hulldigital.co.uk</link>
	<description>Kingston Upon Hull&#039;s Digital Community</description>
	<lastBuildDate>Wed, 01 Feb 2012 21:48:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Hull Digital Developer group &#8211; The story so far</title>
		<link>http://hulldigital.co.uk/hull-digital-developer-group-the-story-so-far/</link>
		<comments>http://hulldigital.co.uk/hull-digital-developer-group-the-story-so-far/#comments</comments>
		<pubDate>Wed, 09 Jun 2010 07:44:09 +0000</pubDate>
		<dc:creator>John Polling</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[hulldigital]]></category>

		<guid isPermaLink="false">http://hulldigital.co.uk/?p=1242</guid>
		<description><![CDATA[With the next Hull Digital Developer group meet-up just around the corner, I thought now would be a good time to let everyone know more about the Developer group and what’s happened so far.]]></description>
			<content:encoded><![CDATA[<p>With the next Hull Digital Developer group meet-up just around the corner, I thought now would be a good time to let everyone know more about the Developer group and what’s happened so far.</p>
<p>We decided to create the group in August last year with the idea of getting together our local developer talent to talk about varying aspects of development and share ideas. The first meet-up was held at Hull University in early December and we had over 30 attendees. The really interesting part was the cross-section of people who attended:</p>
<ul>
<li>business owners</li>
<li>account handlers</li>
<li>designers</li>
<li>front-end web developers</li>
<li>back-end developers</li>
<li>students and lecturers from Hull University</li>
</ul>
<p>For the first meet-up we had two talks. One on the Ruby on Rails ecosystem and the other on the challenges of launching, and growing products on an International level from an office in the pioneering city of Hull. Both talks went down very well with the attendees.</p>
<p>Since then we’ve had two further meet-ups which have proven nearly as popular as the first meet-up and again the cross section of those that attended was similar to the first meet-up.</p>
<p>For details of all the meet-ups so far see the <a href="http://www.meetup.com/Hull-Digital-Hull-Open-Coffee/calendar/past_list">Hull Digital meet-up page</a>.</p>
<h3>Hull University Involvement</h3>
<p>One really great aspect of the group has been the involvement of the University and its students. It’s been really interesting to see how well prepared the students are for when they leave and start searching for work. They are very much up to speed on the latest developments within the industry. If you are looking for new development talent then I would look no further than some of the students graduating from Hull University.</p>
<h3>Why should you attend?</h3>
<p>The developer group offers companies and individuals a great opportunity to enhance their knowledge, and meet like minded people.</p>
<p>To quote a tweet from an attendee to one meet-up</p>
<blockquote><p>“Run a team of devs in Yorks/Humber? Give the team a morning off &amp; send to a #hulldigital dev evening meet for top (free!) teaching.”</p></blockquote>
<p>Still need a reason, then keep reading.</p>
<ul>
<li>Students – gain practical insight into how your academic experience can be applied in the commercial world.</li>
</ul>
<ul>
<li>Freelancers / Agency workers – improve your knowledge and develop collaborative partnerships with other talented developers.</li>
</ul>
<ul>
<li>Business Owners – opportunity to network, find talented freelancers and seek out the best graduates.</li>
</ul>
<h3>The next meet-up</h3>
<p>The next meet-up will be held on 24th June at Fudge Cafe in Hull. We have lined up two excellent and highly respected speakers in Peter Cooper and James Gregory. To find out more about the meet-up, the speakers and their talks go to the <a href="http://www.meetup.com/Hull-Digital-Hull-Open-Coffee/calendar/13735663/">Hull Digital meet-up site</a>.</p>
<h3>The Future – Keeping the momentum rolling</h3>
<p>As with all groups we are reliant on the involvement of local businesses and individuals. We are always looking for suggestions on topics, speakers and even sponsorship. If you can help with any of these, please <a href="http://hulldigital.co.uk/get-in-touch/">let us know</a>.</p>
<p>Finally, we’d like to you to take a few moments and complete the <a href="http://spreadsheets.google.com/viewform?formkey=dEVYenRZVmxrenBmWEVJZFdhbmdxcGc6MA">Hull Digital Developer group questionnaire</a> to help us keep improving the group. Your feedback will be greatly appreciated, it’s only short I promise!</p>
]]></content:encoded>
			<wfw:commentRss>http://hulldigital.co.uk/hull-digital-developer-group-the-story-so-far/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hull Digital Developer Group February Meetup</title>
		<link>http://hulldigital.co.uk/hull-digital-developer-group-february-meetup/</link>
		<comments>http://hulldigital.co.uk/hull-digital-developer-group-february-meetup/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 04:13:06 +0000</pubDate>
		<dc:creator>John Polling</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[hull digital meetup]]></category>
		<category><![CDATA[hulldigital]]></category>
		<category><![CDATA[meetup]]></category>

		<guid isPermaLink="false">http://hulldigital.co.uk/?p=924</guid>
		<description><![CDATA[Following on from the first successful developer meetup that was held in December, we are looking to organise the next meetup for February.  There will be a different format so please let us know your thoughts.]]></description>
			<content:encoded><![CDATA[<p>Following on from the <a title="December Meetup Details" href="http://hulldigital.co.uk/hull-digital-developer-group-2/">first successful developer meetup</a> that was held in December, we are looking to organise the next meetup for February (no specific date just yet).</p>
<p>The format of the next meetup will different to the first as there are not going to be any speakers this time around.  Instead we are hoping to make it a discussion evening, with everyone participating. This should hopefully be  a good way for all the attendees to learn more about each other.</p>
<p>To make the discussions relevant to the majority of developers what we hope to do over the next couple of weeks is gather suggested topics from yourselves, and then ask attendees to vote on the list of topics.  The most popular topics will then be discussed at the meetup.</p>
<p>To get the ball rolling there is a list of topics below.  This list has been created based upon comments from previous blog posts, so thanks to the community for those ideas.</p>
<ol>
<li>Document-oriented Databases (e.g. MongoDB and CouchDB)</li>
<li>Testing Techniques and Tooling</li>
<li>Continuous Integration</li>
<li>The Agile Manifesto</li>
<li>The principles of SOLID</li>
<li>Outside-in Development</li>
</ol>
<p>Clearly there are many, many more topics that could be suggested, so please let us know what is relevant to yourselves.  Whether it&#8217;s front-end web development techniques, or object oriented programming techniques, please let us know.  Remember you don&#8217;t have to be an expert on the topics you suggest, it may well be you know very little and want to talk to other developers to gain a better understanding.</p>
]]></content:encoded>
			<wfw:commentRss>http://hulldigital.co.uk/hull-digital-developer-group-february-meetup/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Fruit Market Revised Development Exhibition</title>
		<link>http://hulldigital.co.uk/fruit-market-revised-development-exhibition/</link>
		<comments>http://hulldigital.co.uk/fruit-market-revised-development-exhibition/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 08:35:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[digital]]></category>
		<category><![CDATA[fruitmarket]]></category>
		<category><![CDATA[future of hull]]></category>
		<category><![CDATA[hull]]></category>
		<category><![CDATA[hull fruitmarket]]></category>
		<category><![CDATA[hulldigital]]></category>

		<guid isPermaLink="false">http://hulldigital.co.uk/?p=862</guid>
		<description><![CDATA[As reported earlier in the year, the Fruit Market is (hopefully) going to be redeveloped into a creative, media and digital space where businesses can flourish, events be held, and it provides a focus / central point in the city for people in working in this area. Today and tomorrow, there is an opportunity for [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://hulldigital.co.uk/hull-fruit-market-meeting-report-interview-with-toby-hyam/" target="_blank">As reported earlier in the year</a>, the Fruit Market is (hopefully) going to be redeveloped into a creative, media and digital space where businesses can flourish, events be held, and it provides a focus / central point in the city for people in working in this area.</p>
<p><strong>Today and tomorrow</strong>, there is an opportunity for us to get involved and see how the plans are progressing (thanks to @duncmc for letting us know about this, and apologies for not letting you know sooner as it is the first we heard about this!).</p>
<p>&#8220;Don’t forget to pop into Arc tomorrow or Friday to see the public exhibition being hosted by Arc on behalf of Hull Forward, of the <strong>Fruit Market revised development brief</strong>. The exhibition is in the <strong>Arc building’s main space on Thursday 19th &amp; Friday 20th November and is open between 10am &#8211; 4pm.</strong></p>
<p>Representatives from Hull Forward and Yorkshire Forward will be staffing the exhibition from 2.30 &#8211; 3.30pm to answer any questions that the you may have about the brief, and Hull Forward are also producing evaluation materials for you to complete if you would like to have your say.</p>
<p>You are also invited to our third ever public Design Review Panel, which takes place from 12.30-2.30pm tomorrow (Thursday) here at Arc.  Hull Forward and Yorkshire Forward will be represented at the Design Review Panel&#8221;.</p>
<p><strong>Who / what is Arc?</strong></p>
<p>Arc is working with people to make great places. They are the architecture centre for Hull and the Humber sub-region, and they’re part of a national network of architecture centres across the UK.</p>
<p>If you can get along, we hope to see you there &#8211; <em>it is important that we help shape the future of Fruit Market to meet the needs of the digital community.</em></p>
<p><em>Please do add your comments and thoughts here, or on the <a href="http://hulldigital.co.uk/hull-fruit-market-meeting-report-interview-with-toby-hyam/" target="_blank">original post</a>.<br />
</em></p>
]]></content:encoded>
			<wfw:commentRss>http://hulldigital.co.uk/fruit-market-revised-development-exhibition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creative Workspaces available at the Fruit Market in Hull</title>
		<link>http://hulldigital.co.uk/creative-workspaces-available-at-the-fruit-market-in-hull/</link>
		<comments>http://hulldigital.co.uk/creative-workspaces-available-at-the-fruit-market-in-hull/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 11:12:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[creative]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[fruitmarket]]></category>
		<category><![CDATA[hull]]></category>
		<category><![CDATA[hulldigital]]></category>
		<category><![CDATA[hullforward]]></category>

		<guid isPermaLink="false">http://hulldigital.co.uk/?p=794</guid>
		<description><![CDATA[We&#8217;re delighted to spread the word about an exciting initiative and event which is coming up shortly. The purpose of the event is to assess the level of potential demand from local businesses and highlight the opportunities for meanwhile uses such as studios, exhibition space and workspace following the relocation of the Wholesale Fruit Market [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;re delighted to spread the word about an exciting initiative and event which is coming up shortly.</p>
<blockquote><p>The purpose of the event is to assess the level of potential demand from local businesses and highlight the opportunities for meanwhile uses such as studios, exhibition space and workspace following the relocation of the Wholesale Fruit Market to Priory Park on the outskirts of the city later this year.</p></blockquote>
<p>You are invited to attend a briefing session about opportunities for creative and media businesses at the Fruit Market, Hull to be held at 62-63 Humber Street (Hull Fruit Market) from 5.30 – 7.30 pm on Thursday 24th September. </p>
<p>Toby Hyam from Yorkshire based Creative Space Management has been commissioned to help Hull Forward to explore the reuse of these properties as quickly as possible pending the long term regeneration of the area. Toby and his colleague Paul Fallon will facilitate the event on the 24th September, providing information about the opportunity and how its supports the delivery of the long term plans for the Fruit Market.</p>
<p>Hull Forward is working closely with Hull City Council and a range of key public and private sector partners to regenerate the area. The partners involved have identified the potential for artists, creative business and social enterprises to get involved and be a major part of the regeneration proposals.</p>
<p>If you are interested in the Fruit Market, either as a location for your business, as a place to try out a new business idea or retail concept or to experiment with performance or installations (storage and passive uses will not be encouraged), please contact <strong>Liz King</strong> to register your interest and to obtain a place at the event. Email: liz.king@hullforward.co.uk Tel: 01482 387420.</p>
<p>Here at Hull Digital, <strong>we fully support this project</strong>. In many cities around the country, there are thriving, successful quarters where the new media and creative industries congregate. It provides a rich crossover of working opportunities, a vibrant atmosphere, as well as attracting businesses like coffee shops and restaurants / cafes.</p>
]]></content:encoded>
			<wfw:commentRss>http://hulldigital.co.uk/creative-workspaces-available-at-the-fruit-market-in-hull/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Hull Digital Developer Group</title>
		<link>http://hulldigital.co.uk/hull-digital-developer-group/</link>
		<comments>http://hulldigital.co.uk/hull-digital-developer-group/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 07:16:10 +0000</pubDate>
		<dc:creator>John Polling</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[hull digital]]></category>
		<category><![CDATA[hull meetup]]></category>

		<guid isPermaLink="false">http://hulldigital.co.uk/?p=776</guid>
		<description><![CDATA[For a while now Hull Digital have been talking about the idea of getting together developers in this area to discuss the varying aspects of development.  ]]></description>
			<content:encoded><![CDATA[<p>For a while now Hull Digital have been talking about the idea of getting together developers in this area to discuss the varying aspects of development.</p>
<h3>Why do we need such a group?</h3>
<p>The speed at which our industry moves is incredible and as developers it is almost impossible for us to keep on top of all aspects of our industry, we can only begin to keep up by working together. Sure we can read books, blog posts and watch screencasts, but there are only 24 hours in a day and we all have lives outside of work as well.</p>
<p>A group would be the perfect place for developers to get together and discuss all things development.  Whether this is Web, Desktop or Mobile based development we&#8217;ve got lots we can discuss with each other.</p>
<h3>Who is the group for?</h3>
<p>The group will be open to anyone wanting to learn and discuss development technologies and techniques. Whether you are a back-end or front-end developer, run a development shop, are a student, or simply a development enthusiast, this group will be for you.</p>
<p>Developers involved in the group should be open minded and not be closed to non-mainstream ideas. The group will not be dedicated to one language, but open to all, as every language can learn ideas and principles from others.</p>
<h3>Possible Format of Development Group</h3>
<p>Initial ideas have been for the group to meet every couple of months.  Clearly this can change dependent on demand.</p>
<p>We are currently thinking that the meetup should be kept in a similar format to the current Hull Digital Meetup, with a couple of speakers and then time to socialise and discuss the evenings talks.</p>
<h3>Topics</h3>
<p>Clearly the world of development is very wide ranging and as such it is hoped the range of topics will be quite large.</p>
<p>Some suggested early topics have been:</p>
<ul>
<li>Test Driven Development</li>
<li>Object-relational Mapping</li>
<li>Principles of SOLID</li>
<li>MVC Frameworks</li>
<li>JavaScript Frameworks</li>
<li>Advanced CSS</li>
<li>Windows Presentation Foundation</li>
<li>Mobile Apps</li>
<li>Cloud Computing</li>
<li>Accessible AJAX (Hijax)</li>
<li>Domain Driven Design</li>
</ul>
<h3>Your thoughts?</h3>
<p>So we can get this group right for you, please let us know what you would like from such a group. Does the proposed format work for you? What kind of topics do you think should be covered?  Would you be prepared to do a talk?</p>
]]></content:encoded>
			<wfw:commentRss>http://hulldigital.co.uk/hull-digital-developer-group/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Using tests to help you create your code</title>
		<link>http://hulldigital.co.uk/using-tests-to-help-you-create-your-code/</link>
		<comments>http://hulldigital.co.uk/using-tests-to-help-you-create-your-code/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 22:03:49 +0000</pubDate>
		<dc:creator>John Polling</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[coding practices]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://hulldigital.co.uk/?p=601</guid>
		<description><![CDATA[This post is going to look at the concept of using test driven development to drive out the code for a project.  
The idea of TDD has been around for quite some time now, but it seems to be gathering favour with more and more developers now.]]></description>
			<content:encoded><![CDATA[<p>This post is going to look at the concept of using test driven development to drive out the code for a project.</p>
<p>The idea of TDD has been around for quite some time now, but it seems to be gathering favour with more and more developers now.</p>
<h3>Brief Overview</h3>
<p>The process of TDD is shown in the stages below</p>
<ol>
<li>Write a test</li>
<li>Check if the test fails</li>
<li>Write the smallest amount of production code to make the test pass</li>
<li>Run the test (Return to step 3 if it fails)</li>
<li><a title="What is code refactoring?" href="http://en.wikipedia.org/wiki/Code_refactoring">Refactor the code</a> (both tests and production code)</li>
</ol>
<p>Theses steps are often referred to as Red (the test fails), Green (the test passes), Refactor.</p>
<h3>TDD in Action</h3>
<p>The easiest way to explain how TDD works is to show some examples.  To do this we are going to look at creating a login page for a website, minus the front end (View).  For these examples we are going to use the following development stack</p>
<ul>
<li>Castle MonoRail (a <a title="Read more about the Model-View-Controller architecture" href="http://en.wikipedia.org/wiki/Model–view–controller">MVC Framework</a> for .Net)</li>
<li>NUnit (a testing framework for .Net)</li>
<li>Rhino Mocks (a mocking framework for .Net)</li>
</ul>
<p>Whilst these may not be <strong>your</strong> development stack, the principles discussed in this post will be roughly the same.</p>
<h4>Starting from scratch</h4>
<p>We are going to be starting completely from scratch with no pre-written code, so the first thing to do is create the <code>LoginController</code> class.  Yes that&#8217;s right we are not going to start with the database first, in fact that will happen much further down the line.</p>
<pre lang="csharp">public class LoginController : SmartDispatcherController
{
}</pre>
<blockquote><p>There is no need to worry about the <code>SmartDispatcherController</code>, this is a MonoRail class that implements <a title="A full explanation of the SmartDispatcherController" href="http://www.castleproject.org/MonoRail/gettingstarted/smartdispatcher.html">smart ways to invoke actions</a>.  Basically it makes our life easier.</p></blockquote>
<p>So we have the empty controller, we need to think about what we want it to do.  This is where TDD comes in. The tests are going to help us create all of the code for the controller and it&#8217;s <a title="See James Gregory's post on dependencies" href="http://hulldigital.co.uk/controlling-your-dependencies/">dependencies</a>.  So let&#8217;s create an empty test fixture for the controller.</p>
<pre lang="csharp">[TestFixture]
public class LoginControllerFixture : BaseControllerTest
{
}</pre>
<blockquote><p>The TestFixture attribute comes from the NUnit framework. It basically means that when NUnit sees this class it knows it has tests to run.</p>
<p>The <code>BaseControllerTest</code> is a MonoRail testing base class which allows us to test controllers without the need for an ASP.Net Runtime</p></blockquote>
<h4>Creating the first test</h4>
<p>Now we have the test fixture ready we can put our first test together.</p>
<p>As we are testing whether users can login in or not, lets start with a test called <code>User_Can_Successfully_Login</code>.</p>
<pre lang="csharp">[TestFixture]
public class LoginControllerFixture : BaseControllerTest
{
	[Test]
	public void User_Can_Successfully_Login()
	{
		var controller = new LoginController();
		PrepareController(controller);
	}
}</pre>
<p>So far we haven&#8217;t done anything much other than create a reference to the <code>LoginController</code> class we created earlier.  The <code>PrepareController</code> method comes from the MonoRail <code>BaseControllerTest</code> and it prepares the controller giving it mock implementations of the services it requires to function normally.</p>
<p>Ok, so we need to actually get this test doing something now.  The important thing to remember here is that we are only testing the controller and nothing else. Following the Single Responsibility Principle, the controller will handle the user input. The handling of the authentication will be done by an <code>AuthenticationService</code> class.</p>
<pre lang="csharp">[TestFixture]
public class LoginControllerFixture : BaseControllerTest
{
	[Test]
	public void User_Can_Successfully_Login()
	{
		var mockery = new MockRepository();
		var authenticationService = mockery.DynamicMock();
		var controller = new LoginController(authenticationService);

		var authenticatedUser = new AuthenticatedUserDTO { Id = Guid.NewGuid(), Type = "Administrator" };
		var authenticationRequest = new AuthenticationRequestDTO {Username = "username", Password = "password"};

		PrepareController(controller);

		With.Mocks(mockery)
			.Expecting(() =&gt; Expect.Call(authenticationService.AuthenticationUser(authenticationRequest)).Return(authenticatedUser))
			.Verify(() =&gt; controller.Login(authenticationRequest));

		Assert.AreEqual("/admin/index", Response.RedirectedTo);
	}
}</pre>
<p>As we currently don&#8217;t have an <code>AuthenticationService</code> class we have added the mocking framework to &#8220;mock&#8221; the service functionality.  The functionality of the service will be tested by the test fixture for that service not by the controller test fixture.</p>
<blockquote><p>A mocking framework allows us to simulate the output of objects, so we don&#8217;t actually have to worry about the implementation of those objects.  Remember we are only testing one unit at a time.</p></blockquote>
<p>Let&#8217;s quickly review the whole test method.</p>
<ol>
<li>Setup the Mock framework</li>
<li>Create a mocked instance of the <code>IAuthenticationService</code> interface</li>
<li>Create and prepare a reference to the controller we are testing and passed in any of it&#8217;s mocked dependencies</li>
<li>Create a <code>AuthenticatedUserDTO</code> object as this is needed by the <code>IAuthenticationService</code></li>
<li>Create a <code>AuthenticationRequestDTO</code> object that will be passed into the <code>Login</code> action</li>
<li>Set the expectations for the controllers <code>Login</code> method &#8211; Expectations are the methods expected to be called by the <code>Login</code> method</li>
<li>Run the <code>Login</code> method via the call to <code>Verify</code></li>
<li>Make sure the method has redirected to the index action of the admin controller by using assertions.</li>
</ol>
<h4>The test is forcing us to generate code</h4>
<p>We have our first test method, however this won&#8217;t compile as we have no <code>IAuthenticationService</code> interface, no <code>AuthenticatedUserDTO</code>, no <code> AuthenticationRequestDTO</code>, no <code>Login</code> method on the <code>LoginController</code> and we are missing the <code>AuthenticationService</code> dependency in the controller, so let&#8217;s get all this added in.</p>
<pre lang="csharp">public class LoginController : SmartDispatcherController
{
	private readonly IAuthenticationService authenticationService;

	public LoginController(IAuthenticationService authenticationService)
	{
		this.authenticationService = authenticationService;
	}

	public void Login([DataBind("login")]AuthenticationRequestDTO authenticationRequest)
	{
	}
}</pre>
<p>We&#8217;ve got the <code>authenticationService</code> dependency and the login action in now.</p>
<pre lang="csharp">public interface IAuthenticationService
{
	AuthenticatedUserDTO AuthenticateUser(AuthenticationRequestDTO authenticationRequest);
}</pre>
<p>Here is our abstraction of the <code>AuthenticationService</code>.  Using the idea of dependency injection we can substitute in any service that inherits from this interface.</p>
<p>As the test has already specified it expects a call to the <code>AuthenticationUser</code> method of the <code>IAuthenticationService</code> interface we can also create the signature of that method.</p>
<pre lang="csharp">public class AuthenticatedUserDTO
{
	public Guid Id { get; set; }
	public string Type { get; set; }
}</pre>
<pre lang="csharp">public class AuthenticationRequestDTO
{
	public string Username { get; set; }
	public string Password { get; set; }
}</pre>
<p>The last two objects are our DTOs (Data Transfer Objects).  These are simple objects that contain no business logic, they are used to transfer data between other objects.</p>
<h4>Run the test</h4>
<p>The code should now compile happily, so we can move on to the next stage of TDD and that is running the test.  Clearly the test will fail as we have no code in the <code>LoginController</code> to make it pass.  Now it may seem pointless running a test when there is no code to make it pass, however if you were writing a test for an edge case you would want to make sure the test wasn&#8217;t passing first, otherwise the test may well be wrong.</p>
<h4>Make the test pass</h4>
<p>When using TDD, the developer should remember they need to write the smallest amount of code possible to make the test pass.</p>
<pre lang="csharp">public class LoginController : SmartDispatcherController
{
	private readonly IAuthenticationService authenticationService;

	public LoginController(IAuthenticationService authenticationService)
	{
		this.authenticationService = authenticationService;
	}

	public void Login([DataBind("login")]AuthenticationRequestDTO authenticationRequest)
	{
		var authenticatedUser = authenticationService.AuthenticationUser(authenticationRequest);

		Redirect("Admin", "Index");
	}
}</pre>
<p>If we now run the test it will pass. The final stage of the TDD process is to refactor the code. At this stage there is no code that can be refactored, so we&#8217;ll move on.</p>
<h4>Test the negative and positive</h4>
<p>We are not finished here as we need to test that the controller can cope when a user enters incorrect details.  Let&#8217;s look at creating a <code>User_Can_Fail_Login</code> test.</p>
<pre lang="csharp">[Test]
public void User_Can_Fail_Login()
{
	var mockery = new MockRepository();
	var authenticationService = mockery.DynamicMock();
	var controller = new LoginController(authenticationService);

	var authenticationRequest = new AuthenticationRequestDTO {Username = "username", Password = "password"};

	PrepareController(controller);

	With.Mocks(mockery)
		.Expecting(() =&gt; Expect.Call(authenticationService.AuthenticationUser(authenticationRequest)).Return(new AuthenticatedUserDTO()))
		.Verify(() =&gt; controller.Login(authenticationRequest));

	Assert.AreEqual(1, controller.Flash.Count);
	Assert.AreEqual("Username or Password not recognised", controller.Flash["error"]);
}</pre>
<p>The difference here from the successful login test is that the mocked <code>authenticationService</code> returns an empty instance of the AuthenticatedUserDTO object.  We also have changed the assertions to make sure that an error has been placed into the <a title="What is Flash?" href="http://castleproject.org/monorail/documentation/v1rc2/usersguide/flash.html">MonoRail Flash parameter</a>.  Now if we run the overall test fixture we will have one passing and one failing test, so we need to revisit the <code>LoginController</code> class and make the second test pass.</p>
<pre lang="csharp">public class LoginController : SmartDispatcherController
{
	private readonly IAuthenticationService authenticationService;

	public LoginController(IAuthenticationService authenticationService)
	{
		this.authenticationService = authenticationService;
	}

	public void Login([DataBind("login")]AuthenticationRequestDTO authenticationRequest)
	{
		var authenticatedUser = authenticationService.AuthenticationUser(authenticationRequest);

		if (authenticatedUser.Id != Guid.Empty)
			Redirect("Admin", "Index");
		else
		{
			Flash["error"] = "Username or Password not recognised";
			RedirectToReferrer();
		}
	}
}</pre>
<p>If we run the tests now, we should have two passing tests.</p>
<h4>Refactor all our code</h4>
<p>Again as part of the TDD process we need to look at refactoring our code, this includes the test fixture code as well.  From looking at the controller code there isn&#8217;t anything that can be refactored, however the test fixture is suffering from DRYness (Don&#8217;t Repeat Yourself).</p>
<p>Let&#8217;s look at the whole test fixture class again.</p>
<pre lang="csharp">[TestFixture]
public class LoginControllerFixture : BaseControllerTest
{
	[Test]
	public void User_Can_Successfully_Login()
	{
		var mockery = new MockRepository();
		var authenticationService = mockery.DynamicMock();
		var controller = new LoginController(authenticationService);

		var authenticatedUser = new AuthenticatedUserDTO { Id = Guid.NewGuid(), Type = "Administrator" };
		var authenticationRequest = new AuthenticationRequestDTO {Username = "username", Password = "password"};

		PrepareController(controller);

		With.Mocks(mockery)
			.Expecting(() =&gt; Expect.Call(authenticationService.AuthenticationUser(authenticationRequest)).Return(authenticatedUser))
			.Verify(() =&gt; controller.Login(authenticationRequest));

		Assert.AreEqual("/admin/index", Response.RedirectedTo);
	}

	[Test]
	public void User_Can_Fail_Login()
	{
		var mockery = new MockRepository();
		var authenticationService = mockery.DynamicMock();
		var controller = new LoginController(authenticationService);

		var authenticationRequest = new AuthenticationRequestDTO {Username = "username", Password = "password"};

		PrepareController(controller);

		With.Mocks(mockery)
			.Expecting(() =&gt; Expect.Call(authenticationService.AuthenticationUser(authenticationRequest)).Return(new AuthenticatedUserDTO()))
			.Verify(() =&gt; controller.Login(authenticationRequest));

		Assert.AreEqual(1, controller.Flash.Count);
		Assert.AreEqual("Username or Password not recognised", controller.Flash["error"]);
	}
}</pre>
<p>You should be able to see the duplication quite clearly.  So we need to clean this up.</p>
<pre lang="csharp">[TestFixture]
public class LoginControllerFixture : BaseControllerTest
{
	private MockRepository mockery;
	private IAuthenticationService authenticationService;
	private LoginController controller;
	private AuthenticationRequestDTO authenticationRequest;

	[SetUp]
	public void SetUp()
	{
		mockery = new MockRepository();
		authenticationService = mockery.DynamicMock();
		controller = new LoginController(authenticationService);

		authenticationRequest = new AuthenticationRequestDTO {Username = "username", Password = "password"};

		PrepareController(controller);
	}

	[Test]
	public void User_Can_Successfully_Login()
	{
		mockLoginAction(new AuthenticatedUserDTO { Id = Guid.NewGuid(), Type = "Administrator" });

		Assert.AreEqual("/admin/index", Response.RedirectedTo);
	}

	[Test]
	public void User_Can_Fail_Login()
	{
		mockLoginAction(new AuthenticatedUserDTO());

		Assert.AreEqual(1, controller.Flash.Count);
		Assert.AreEqual("Username or Password not recognised", controller.Flash["error"]);
	}

	private void mockLoginAction(AuthenticatedUserDTO authenticatedUser)
	{
		With.Mocks(mockery)
			.Expecting(() =&gt; Expect.Call(authenticationService.AuthenticationUser(authenticationRequest)).Return(authenticatedUser))
			.Verify(() =&gt; controller.Login(authenticationRequest));
	}
}</pre>
<p>You can see here we&#8217;ve cleaned up the test fixture quite a bit.</p>
<p>The first thing we&#8217;ve used here is the built in testing framework <code>SetUp</code> method.  This method is run before every test method is run, so we can use it to prepare everything we are going to need for each test.</p>
<p>The second thing we have done is to move the mocking code into a private method that both test methods can use at once.</p>
<p>Once we have finished refactoring any code we need to run the tests again to make sure we haven&#8217;t broken anything.</p>
<h3>Conclusion</h3>
<p>So from starting with an empty controller class we have used two tests to drive out our code and we now have a fully tested controller, with an abstract dependency and two <a title="What are Data Transfer Objects" href="http://en.wikipedia.org/wiki/Data_transfer_object">DTO</a>s.  Clearly we need to add in some method of keeping the user logged in, using a cookie or session variable, but this isn&#8217;t going to be done now as this post would be much longer!</p>
<p>Yes we have written more code that we would have done by just simply writing the controller without tests, however these tests are some major benefits for the future.</p>
<ol>
<li>We&#8217;ll know if we brake anything in the future as we can keep running the tests at any stage</li>
<li>If a new developer starts to work on the code, they will be able to read the tests and understand what the controller should be doing.  That&#8217;s right, we have written some documentation for them!</li>
<li>To run these tests we&#8217;ve not had to ramp up any database or test data</li>
<li>We&#8217;ve not had to set up any web server to test the code</li>
<li>Developers can have rapid feedback on any development work they are doing, by running the tests as often as they want</li>
<li>The controller is <a href="http://en.wikipedia.org/wiki/Loose_coupling">loosely coupled</a> with it&#8217;s dependency (<code>AuthenticationService</code>), so we can change the service at any stage, as long as it inherits from the abstract version of the service.</li>
</ol>
<p>Now we have our controller we can then use the same TDD ideas to drive out the code for the abstract service object we have. This will, more than likely, lead to the driving out of other abstract objects.</p>
<p>Once we have all these objects written we can then use the idea of <a href="http://en.wikipedia.org/wiki/Integration_testing">integration tests</a> to make sure all the objects work together without any mocking.</p>
]]></content:encoded>
			<wfw:commentRss>http://hulldigital.co.uk/using-tests-to-help-you-create-your-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Controlling your dependencies</title>
		<link>http://hulldigital.co.uk/controlling-your-dependencies/</link>
		<comments>http://hulldigital.co.uk/controlling-your-dependencies/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 19:45:48 +0000</pubDate>
		<dc:creator>John Polling</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[coding practices]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[hull digital]]></category>

		<guid isPermaLink="false">http://hulldigital.co.uk/?p=584</guid>
		<description><![CDATA[Dependencies take many forms. You're dependent on your car (shame on you!) to get to work. Your pet depends on you to feed it. You depend on your employer paying you for your work, and your employer depends on you to actually produce the work.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m going to talk about Dependency Injection, and I&#8217;ll be using Ruby for most of the examples. First though, we&#8217;ll cover what a dependency is.</p>
<p>Dependencies take many forms. You&#8217;re dependent on your car (shame on you!) to get to work. Your pet depends on you to feed it. You depend on your employer paying you for your work, and your employer depends on you to actually produce the work.</p>
<p>You may not think much about these in daily life, but every thing that you rely on reduces your control over your situation. For those commuters among us, if you take a train to get to work you&#8217;re probably already aware that you have no control over whether it arrives on time; without that control you&#8217;re indirectly out-of-control of what time you arrive to work.</p>
<p>Dependencies are unavoidable. To stop depending on the trains you could take your car, but that&#8217;s just shifting the buck; you work from home, but then you&#8217;re reliant on your broadband and electricity being available. They&#8217;re unavoidable, it&#8217;s how you manage them that&#8217;s important.</p>
<p>Sometimes you need to think at a higher-level than where your dependency is affecting you. You may not be able to control the trains, but you can control your <em>need</em> for the trains. Substitution is best method for maintaining control. Being able to substitute your mode of transportation for another without consequence would seriously improve your situation.</p>
<h3>Dependencies in your code</h3>
<p>Let&#8217;s play spot the dependencies.</p>
<pre><code>class ChatSession
  attr_accessor :session_id

  def initialize
    @server = ChatServer.new
  end

  def get_latest_messages
    messages = @server.get_messages session_id, :since =&gt; @last_request_time
    @last_request_time = DateTime.now
   messages
  end
end</code></pre>
<p>There&#8217;s a couple in there, can you spot them? The main one is that we&#8217;re depending on a <code>ChatServer</code> instance. We&#8217;re also depending on <code>DateTime</code>, but we&#8217;ll leave that one alone for now. By instantiating the <code>ChatServer</code> in the constructor, we&#8217;ve lost control of how our class works.</p>
<blockquote><p>There&#8217;s a core tenet of Object Oriented Programming called the <a href="http://en.wikipedia.org/wiki/Open/closed_principle">Open/Closed Principal</a>. This states that modules should be open for extension, but closed for modification. Put simply, this means you should be able to modify the behavior of your classes without changing their code.</p></blockquote>
<p>If we decided that our chat client was going to be distributed rather than centralized, then we&#8217;d have to modify this class. We&#8217;d have to modify all classes that instantiate a <code>ChatServer</code>. This design is brittle, because a single design change can ripple out across your entire code-base requiring many small changes.</p>
<p>How exactly do you close a class for modification, but still allow extension? I&#8217;ll show you.</p>
<pre><code>def initialize(server_class)
  @server = server_class.new
end
</code></pre>
<p>We&#8217;re now passing in the class of server into our constructor, which is a technique called <a href="http://docs.codehaus.org/display/PICO/Constructor+Injection">Constructor Injection</a>; we&#8217;d create it like so: <code>ChatSession.new(ChatServer)</code>. <code>ChatSession</code> is now independent of server implementation details and can operate with any server; we can now potentially swap out to use a <code>DistributedChatServer</code> or more practically, substitute the server in a test to verify our class more easily.</p>
<blockquote><p>Those of you who&#8217;ve used dependency injection in a static language (such as C# or Java) may be wondering why we&#8217;re passing the Type in, instead of an actual instance. We&#8217;re doing this because it&#8217;s more flexible when combined with the dynamic nature of Ruby. For instance you could throw in a <code>respond_to?</code> call to check if the type is capable of doing something special, and if not fall back on the regular constructor; we couldn&#8217;t do this if we&#8217;d only received an instance.</p></blockquote>
<p>While overloading the constructor like this can be very useful, it does lead us into producing more code when we instantiate classes. The more arguments you add, the less it scales. Statically typed languages favor using a Dependency Injection framework to alleviate this problem (I&#8217;ll cover them soon), but as we&#8217;re currently talking in Ruby we&#8217;re going to keep things simple.</p>
<pre><code>def initialize(server_class=ChatServer)
  @server = server_class.new
end
</code></pre>
<p>We&#8217;ve altered our constructor is now using the <a href="http://www.wellho.net/resources/ex.php4?item=r104/llen">default parameter</a> support from Ruby to supply the most common scenario to our instance. Most of the time we&#8217;re going to use the standard<code>ChatServer</code> so it makes sense to default to that and only supply a different one for those special cases. This gives us back our ability to use a plain <code>new</code>. We now satisfy the Open/Closed Principal, because we can now modify the class&#8217;s behavior by supplying a different server instance without having to modify any of it&#8217;s code.</p>
<blockquote><p><strong>Q: We&#8217;d still need to modify every class that creates a default ChatServer if we wanted to swap it out entirely, wouldn&#8217;t we?</strong></p>
<p>A: Correct, this design is mainly intended for allowing easier occasional substitution (present in unit tests mainly). If you wanted full independence from any references to concrete implementations in your dependents, then you could use a variety of other injection patterns, or simply not supply the default to achieve this. Some examples are using a factory method with subclassing, a property to set on construction, or a type supplied directly to the method that uses it. Ruby is dynamic, do whatever works for you.</p></blockquote>
<p>It&#8217;s fairly accepted in Ruby circles that there isn&#8217;t the need for frameworks to do Dependency Injection, as the language is flexible enough to let you do it easily enough yourself; <a href="http://weblog.jamisbuck.org/">Jamis Buck</a> covers this position nicely in his <a href="http://weblog.jamisbuck.org/2008/11/9/legos-play-doh-and-programming">LEGOs, Play-Doh, and Programming</a> blog post; however, not all languages have this ability, and it&#8217;s these that generally utilise frameworks to help with dependency injection.</p>
<p>In static language Dependency Injection frameworks are what tie everything together. They allow you to specify your dependencies via constructors and have them auto-magically injected at run-time. If you have your container configured to pick up all your available classes on startup, then extending a class is as simple as changing the constructor, everything else happens automatically.</p>
<p>Our Ruby example would be configured using <a href="http://structuremap.sourceforge.net/">StructureMap</a> (a .Net dependency injection framework) like so:</p>
<pre><code>public class ServerRegistry : Registry
{
  public ServerRegistry()
  {
    Scan(x =&gt;
    {
      x.TheCallingAssembly();
      x.WithDefaultConventions();
    });

    ForRequestedType&lt;IChatServer&gt;()
      .TheDefaultIsConcreteType&lt;CenteralizedChatServer&gt;();
  }
}
</code></pre>
<p>The <code>Registry</code> is StructureMap&#8217;s convention for configuring the container, and it&#8217;s <code>Scan</code> method auto-discovers all injectable types, and the <code>ForRequestedType</code> method-chain configures our application to use the <code>CenteralizedChatServer</code> as the default instance for any consumers of an <code>IChatServer</code>. It&#8217;s that last part that we&#8217;d be able to switch on an external variable to use a <code>DistributedChatServer</code> if needed.</p>
<p>There are dependency injection frameworks for almost every language, even for those that don&#8217;t really need them. .Net has <a href="http://structuremap.sourceforge.net/">StructureMap</a>, <a href="http://www.castleproject.org/container/index.html">Windsor</a>, and <a href="http://ninject.org/">Ninject</a> (as well as several more); Java has <a href="http://www.springsource.org/">Spring</a>, <a href="http://code.google.com/p/google-guice/">Google Guice</a>, and others; php has <a href="http://components.symfony-project.org/dependency-injection/">Symfony</a> and <a href="http://phpcrafty.sourceforge.net/">Crafty</a>; and even though Ruby and Python don&#8217;t really need them, they have <a href="http://rubyforge.org/projects/needle/">Needle</a> and <a href="http://code.google.com/p/snake-guice/">Snake Guice</a> respectively.</p>
<p>I know what you&#8217;re thinking, &#8220;sure this sounds nice, but isn&#8217;t it just more work? How does it actually make my life easier?&#8221;.</p>
<p>The fewer dependencies that your classes have, the fewer reasons they have to change; the fewer reasons they have to change, the less work you have to do; the less work you have to do, the more time you can spend doing more fun things (whether they&#8217;re more interesting programming tasks, or life outside the screen). <em>That would be nice, wouldn&#8217;t it?</em></p>
<h3>Quick Thanks</h3>
<p>I&#8217;d just like to give James Gregory a huge thanks for writing this post.  James is the project lead for <a title="Find out more about Fluent NHibernate" href="http://fluentnhibernate.org/">Fluent NHibernate</a> and is the founder of <a title="Find out about Proof of Concept" href="http://proofisgood.com/">Proof of Concept Ltd</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://hulldigital.co.uk/controlling-your-dependencies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maintainable Code</title>
		<link>http://hulldigital.co.uk/maintainable-code/</link>
		<comments>http://hulldigital.co.uk/maintainable-code/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 09:46:44 +0000</pubDate>
		<dc:creator>John Polling</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[coding practices]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://hulldigital.co.uk/?p=453</guid>
		<description><![CDATA[Let's face it, we all know that when we sit down and start coding anything, the requirements are going to change and once we have released the code into the wild our clients are going to want updates. ]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s face it, we all know that when we sit down and start coding anything, the requirements are going to change and once we have released the code into the wild our clients are going to want updates.  So the real challenge with coding is writing something that can be easily maintained, whilst remembering that it may not be ourselves doing the maintenance.</p>
<p>Maintainability is probably the single most important thing in software development, so why is it that so often code becomes difficult to maintain, and the older the code gets the more difficult it becomes to maintain?  This post will give a very brief overview of some common techniques that should be remembered to help improve maintainability.</p>
<h3>Meaningful and Consistent Naming Conventions</h3>
<p>The first thing to remember is that someone else may be reading your code, and thus it is important that they can understand what a class, method or variable is doing based on the name given to it.  This is particular important with larger projects where developers need to be able to find functionality quickly, otherwise maintenance costs will increase.</p>
<p>There are quite a number of standard naming conventions around, so once you have picked one, stick to it.  If possible use tools that help you stick to those conventions.</p>
<h3>Remove &#8220;Code Smells&#8221;</h3>
<p>One of the major problems with code is that is can be full of &#8220;code smells&#8221; and over time the code can rot more and more.  Some of the common code smells are</p>
<ul>
<li>Duplicate code</li>
<li>Large methods</li>
<li>Large classes</li>
<li>Excessive commenting</li>
<li>Conditional complexity</li>
<li>Dead code</li>
</ul>
<p>For a fuller list with explanations read the <a title="What are code smells?" href="http://www.codinghorror.com/blog/archives/000589.html">Code Smells article on Coding Horror</a>.</p>
<h3>Separation of Concerns</h3>
<p><abbr title="Separation of Concerns">SoC</abbr> is about breaking the software into distinct pieces of functionality.  On a simple level this may mean separating the <abbr title="User Interface">UI</abbr> layer, the business logic layer and the database access layer.  If functionality is not separated out then it becomes difficult for developers to pin point the area they need to update during maintenance.  It is also likely that this mixed functionality will lead to making changes more complicated, due to code being reliant on other areas of code.</p>
<p>A major benefit of SoC is that it generally leads to much smaller methods and classes, thus improving the readability of code.  It also improves the ability to test each area of functionality.</p>
<h3>Loose Coupling</h3>
<p>Coupling is the measure by which each object relies on other objects.  If objects are loosely coupled a change to one object will have a minimal effect on all other objects.  One way of loosely coupling objects is to follow the <a href="http://www.martinfowler.com/articles/injection.html">Dependency Injection</a> pattern.</p>
<h3>Testability</h3>
<p>Testing is an essential part of software maintenance.  If code is not covered by tests then it becomes difficult and time consuming for developers to check if updates have caused knock on effects in other areas of the software. Ideally a developer should be looking to practice <a href="http://martinfowler.com/articles/continuousIntegration.html">Continuous Integration</a>, and a build server should run the tests whenever new code is checked in.  This way the team members will know quickly if the build has broken and problems can be resolved quickly.</p>
<h3>Final Thoughts</h3>
<p>There are many more areas to creating maintainable code that haven&#8217;t been mentioned above, the purpose of this post is to act as a starting point.</p>
<p>Please lets us know how you ensure your code is easy to maintain.</p>
]]></content:encoded>
			<wfw:commentRss>http://hulldigital.co.uk/maintainable-code/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

