Friday, 2 December 2011

Agile World Breakfast Seminar

Yesterday I attended my second Agile World Breakfast Seminar given by Cake Solutions at Hays IT's offices on Cheapside in the centre of London. I was coming from Norwich so it meant getting the 5.25am train. An early start but well worth it.

A breakfast seminar is probably just as you imagine. You turn up at 8am, you're given a nice breakfast and the chance to network before attending the seminar. Following the seminar there is more opportunity to network. It's mostly over by 10am.

I'm being completely honest when I say I go for the networking and to catch up with the Cake Solutions team. The level of Agile given by Jan Machacek was introductory. It was solid, interesting and perfectly pitched for the majority of the audience. What sets Jan and Cake Solutions apart from other Agile organisations is that they are able to speak about their experience. Many Agile evangelists (consultant appears to be becoming a dirty word) are unable to do this.

I only took issue with one suggestion towards the end which suggested that using an Agile methodology could make your team appear to be going slower. Jan gave some metrics, but I think the missing point was that with traditional software development (Waterfall etc.) the only yard stick the business has are the metrics supplied by the development team. With an Agile team the metrics don't necessarily look so good, but the major advantage is that the business can see working software at the end of each iteration which is a far greater indication of real progress.

There were some very interesting and revealing questions about the collaborative software development process that Cake Solutions offers its clients. It was clear that there is a similar amount of risk on both sides, but the risk for the client is significantly reduced from more traditional methods of working.

The next seminar will be on the financial aspects of Agile development. I'm looking forward to more networking and more content relevant to me personally.

Wednesday, 30 November 2011

Learning UML 2.0

Russ Miles & Kim Hamilton
ISBN: 978-0596009823

I have never been a big fan of UML or really seen the need for it. However I was told it was imperative for my latest contract, so I out my old copy of UML distilled by Martin Fowler and bought a new copy of it for my Kindle and started reading it. I had been with my new client very long when someone recommended Learning UML 2.0 by Russ Miles and Kim Hamilton. It contains the Philippe Kruchten 4+1 model that we would be using for the project so I thought it would probably make a better book to learn from (no pun intended).

Philippe Kruchten 4+1 Model
Philippe Kruchten 4+1 Model

This is a great book. Easy to read and lots of detail about the key areas of UML 2.0. It doesn't cover absolutely everything, but recommends other books that do. There are lots of code examples in Java. I'm not sure if all of these are useful or if the authors, who are programmers, were just desperate to get some code in.

The book focuses on what in my opinion are the most useful diagrams:
  • Use Cases
  • Activity Diagrams
  • Class Diagrams
  • Object Diagrams
  • Sequence Diagrams
  • Communication Diagrams
  • Timing Diagrams
  • Interaction Overview Diagrams
  • Composite Structures
  • Component Diagrams
  • State Machine Diagrams
  • Deployment Diagrams
I hesitate to include Class diagrams in the list. Along with Use Cases and Sequence diagrams, class diagrams are probably the most well known of all UML diagrams. Unlike sequence diagrams and to a certain extent Use Cases, class diagrams are of little use. Usually it's quicker to get on and write the code than it is to draw diagrams and get someone else to write it. One possible exception is where you are generating code from a UML model, but I don't really see the point in that either. Fortunately there are only two chapters on Class Diagrams.

In my opinion if you want to learn the important parts of UML in a hurry. This is the book for you.

Thursday, 17 November 2011

Review of Effective C# Item 15: Utilize using and try-finally for Resource Clean-up

The original Effective C++ Series from Scott Meyers was a real revelation for C++ programmers. It grouped together many idioms from the wildly diverse and complex language and made them understandable. It identified many of the pitfalls and made them avoidable. It was a must read for every serious C++ programmer.

Since then all the major language seems to have an effective series. You would think this was a good idea, but most languages are not as wildly complex as C++, with fewer idioms and pitfalls. They're still there, but the languages have been designed with the idioms in mind, and the introductory texts teach them, and with a lot of the pitfalls already avoided. Consequently most effective series for modern languages are smaller and contain a lot of patterns as well. For example, Effective Java starts off with the builder pattern. To my mind that belongs in a patterns book and it certainly should not be the first Java idiom described.

I am currently reading Effective C# by Bill Wagner. I've got as far as chapter 18 and so far it is full of good advice, but, in my opinion, is extremely poorly explained. Items 6 and 7 cover equality and GetHashCode. These are complex concepts in predominantly reference based languages, like C#, and after I'd finished reading the items I didn't feel I understood them much better.

Items 12 to 20 cover resource management. This is a real passion of mine, so naturally I'm quite critical of what's written here, as well as what's actually written. Luckily most of what's written is sound, but part of Item 15 gives, in my opinion, some just plain bad advice. The following item, 16, is another exceptionally badly written item, all though the advice is sound, but I'll leave that for another time.

Item 15: Utilize using and try-finally for Resource Clean-up Resource management is probably the biggest Achilles heal of garbage collected languages. As such, it should probably be the subject of the first section of any effective series, but item 15 out of 50 isn't to bad.

How and why resources need to be managed in C# is explained satisfactorily by the item, so I won't go over it again. However I was highly amused by one paragraph: "Luckily for you, the C# language designers knew that explicitly releasing resources would be a common task. They added keywords to the language to make it easy." Surely this is treating a symptom, not solving the problem and they should have found a way to encapsulate resource management within types.

My real issue with this item is what the author describes as an ugly construct. There is an implied using example that uses both a SqlConnection and a SqlCommand:
public void ExecuteCommand(string connString, string commandString)
{
using (var myConnection = new SqlConnection(connString))
{
using(var myCommand = new SqlCommand(commandString, myConnection))
{
myConnection.Open();
myCommand.ExecuteNonQuery();
}
}
}
The author points out that you've effectively written this construct:
public void ExecuteCommand(string connString, string commandString)
{
SqlConnection myConnection = null;
SqlCommand myCommand = null;

try
{
myConnection = new SqlConnection(connString);
try
{
myCommand = new SqlCommand(commandString, myConnection);

myConnection.Open();
myCommand.ExecuteNonQuery();
}
finally
{
if (myCommand != null)
myCommand.Dispose();
}
}
finally
{
if (myConnection != null)
myConnection.Dispose();
}
}
As he finds it ugly, when allocating multiple objects that implement IDispose, he prefers to write his own try/finally blocks:
public void ExecuteCommand(string connString, string commandString)
{
SqlConnection myConnection = null;
SqlCommand myCommand = null;

try
{
myConnection = new SqlConnection(connString);
myCommand = new SqlCommand(commandString, myConnection);

myConnection.Open();
myCommand.ExecuteNonQuery();
}
finally
{
if (myConnection != null)
myConnection.Dispose();

if (myCommand != null)
myCommand.Dispose();
}
}
I have two problems with this. The first is that if the Finally For Each Release pattern, as described by Kevlin Henney in Another Tale of Two Patterns, is correctly implemented, the null checks, which are a terrible code smell and often the cause of bugs if they get forgotten, would be completely unnecessary:
public void ExecuteCommand(string connString, string commandString)
{
var myConnection = new SqlConnection(connString);

try
{
var myCommand = new SqlCommand(commandString, myConnection);

try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
}
finally
{
myCommand.Dispose();
}
}
finally
{
myConnection.Dispose();
}
}
If the nested try blocks are a problem for you, another method can be introduced:
public void ExecuteCommand(string connString, string commandString)
{
var myConnection = new SqlConnection(connString);

try
{
ExecuteCommand(myConnection, commandString);
}
finally
{
myConnection.Dispose();
}
}

private void ExecuteCommand(SqlConnection myConnection, string commandString)
{
var myCommand = new SqlCommand(commandString, myConnection);

try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
}
finally
{
myCommand.Dispose();
}
}
However, the real problem is that you are only effectively implementing this construct. If you stick with the original nested using blocks, the compiler creates the construct for you and you don't see it. Which means that it really doesn't matter how ugly it might be and ditching the using blocks and writing your own construct just creates the ugliness. Maybe the root of the authors aesthetic objection is the nesting. Again, this is easily overcome by introducing another function:
public void ExecuteCommand(string connString, string commandString)
{
using (var myConnection = new SqlConnection(connString))
{
ExecuteCommand(myConnection, commandString);
}
}

private void ExecuteCommand(SqlConnection myConnection, string commandString)
{
using (var myCommand = new SqlCommand(commandString, myConnection))
{
myConnection.Open();
myCommand.ExecuteNonQuery();
}
}
Finally
In conclusion, the final part of the summary advice given in the chapter which states, "Whenever you allocate one disposable object in a method, the using statement is the best way to ensure that the resources you allocate are freed in all cases. When you allocate multiple objects in the same method, create multiple using blocks or write your own single try/finally block." should be ignored in favour of "... When you allocate multiple objects in the same method, create multiple using blocks."

A PDF version of this review can be found here.

Tuesday, 15 November 2011

First Agile East Anglia Meeting

It’s a little later than I was planning for but I’ve fixed a date, time and venue for the first Agile East Anglia meeting:

Date: 5 December 2011
Time: 6.30pm to 8.30pm
Venue: Coach & Horses, Thorpe Road, Norwich

I’ll aim to get there between 6pm and 6.30pm and will be there until at least 8.30pm. There are at least two Coach & Horses in Norwich. Please make sure you come to the one on Thorpe Road near the Railway Station in Norwich. Please try and let me know if you intend to come. Either by replying to this message or emailing me: paul.grenyer@gmail.com.

As with XTC in London, there’s no agenda or format. It’s just an opportunity for those interested in or practicing Agile to get together for an informal chat. In the future if people would like to have more structure or speakers, that can be arranged. Please feel free to bring anyone else interested along with you.

Although XTC meet weekly I think that might be a little optimistic for Norwich at this stage. So if all goes well I’ll plan the next meeting for early January.

I look forward to seeing you all.

Sunday, 13 November 2011

Opeth

O2 Academy Birmingham
Saturday 12th November 2011

The last time I was a the Academy in Birmingham was February two years ago for Lamb of God and Dimmu Borgir. Both were very good, but the people there were rude and inconsiderate. Last night was very, very different. Lots of friendly people and the staff were great. In fact London venues have a lot to learn.

Opeth did not play a single song that I would have asked for! Having resisted the urge to play their new album all the way through, they instead opted for a more progressive, less death metal approach, playing both some new and old songs. There's was no Blackwater Park and no Daemon of the Fall. Mikael Ã…kerfeldt was on fine form. Talking to the audience for long periods between songs, even getting the audience to participate in a Napalm Death cover. I loved it! Can't wait to see them again.

The Devil's Orchard
I Feel The Dark
Face of Melinda
Porcelain Heart (with drum solo)
Nepenthe
The Throat of Winter
Credence
Closure
You Suffer (Napalm Death cover)
You Suffer (Napalm Death cover)
You Suffer (Napalm Death cover)
You Suffer (Napalm Death cover)
Slither
A Fair Judgement
Hex Omega
Folklore

Thursday, 10 November 2011

Working Effectively with Legacy Code

by Michael Feathers

ISBN-13: 978-0131177055

This is my second read through of Working Effectively with Legacy Code. I don’t usually read books twice, but it was being used as the material for an ACCU Mentored Developers project I was running.

Working Effectively with Legacy Code is almost as relevant now as when I read it in 2007. The only real thing that dates it are some of the links to pages that have moved on and some of the techniques which were new then, but are far more widely understood now. A credit to the book in a lot of ways.

Both times that I read it I felt that it didn’t teach me much that I hadn’t already learned during my career. I have been exceptionally fortunate to have worked with or been associated with some of the best developers in the world, so it was inevitable that I would pick this stuff up. Many developers are not so fortunate and that is why this book remains in my top ten.

All of that aside, this book contains surprisingly practical advice. I remember seeing Michael Feathers presenting at an ACCU conference and the room, including myself, being up in arms about using inheritance to mock out the methods of a class under test. Now I’ve read the book I understand that is just a first step to get the class under test before you refactor.

Singleton is a pattern that comes up again and again in all sorts of books (I’m reading a UML book at the moment and it’s even there!). One of the problems with singleton is that it is difficult to test. Feathers shows how you can get a singleton in existing code under test before you refactor it out. This is not the same as advocating singletons.

Feathers describes techniques for getting code under test that I had considered in the past and dismissed as far too complicated to be useful, but he makes them simple and straightforward. I could go on and on with example after example but the bottom line is that even if you’ve been fortunate in your career, you should read this book to get even the smallest bits that you haven’t considered.

Wednesday, 9 November 2011

Catalina-Ant for Tomcat 7

I recently upgraded from Tomcat 6 to Tomcat 7 and all of my Ant deployment scripts stopped working. I eventually worked out why and made the necessary changes, but there doesn’t seem to be a complete description of how to use Catalina-Ant for Tomcat 7 on the web so I thought I'd write one.
  1. To start with, make sure Tomcat manager is configured for use by Catalina-Ant. Make sure that manager-script is included in the roles for one of the users in TOMCAT_HOME/conf/tomcat-users.xml. For example:
    <tomcat-users>
    <user name="admin" password="s3cr£t" roles="manager-gui,manager-script"/>
    </tomcat-users>
  2. Catalina-Ant for Tomcat 6 was encapsulated within a single JAR file. Catalina-Ant for Tomcat 7 requires four JAR files. One from TOMCAT_HOME/bin:

    tomcat-juli.jar

    and three from TOMCAT_HOME/lib:

    catalina-ant.jar
    tomcat-coyote.jar
    tomcat-util.jar


    There are at least three ways of making the JARs available to Ant:

    1. Copy the JARs into the ANT_HOME/lib folder. Then Ant will just find them.
    2. Copy the JARs to a folder within your project that you check into your source control system. Ant then needs a path id to find them:
      <path id="catalina-ant-classpath">
      <fileset dir="${catalina-ant-dir}">
      <include name="catalina-ant.jar"/>
      <include name="tomcat-coyote.jar"/>
      <include name="tomcat-util.jar"/>
      <include name="tomcat-juli.jar"/>
      </fileset>
      </path>
      Where catalina-ant-dir is the directory with the JARs in. This way you don’t need to modify the Ant installation on every machine you build on.
    3. Access the JARs directly from your Tomcat 7 installation. Ant then needs a path id to find them:
      <path id="catalina-ant-classpath">
      <fileset dir="${appserver.lib}">
      <include name="catalina-ant.jar"/>
      <include name="tomcat-coyote.jar"/>
      <include name="tomcat-util.jar"/>
      </fileset>
      <fileset dir="${appserver.home}/bin">
      <include name="tomcat-juli.jar"/>
      </fileset>
      </path>
      Where appserver.lib is the path to Tomcat 7’s lib directory and appserver.home is the path to Tomcat’s top level installed directory. This way Tomcat 7 is required on every box you build on.

    My personal preference is for 2 above.

  3. Now that your Ant script can see the Catalina-Ant JARs you need to tell it what tasks are available. These are most if not all of the tasks that are available to Ant.
    <taskdef name="catalina-deploy" classname="org.apache.catalina.ant.DeployTask" classpathref="catalina-ant-classpath"/>
    <taskdef name="catalina-list" classname="org.apache.catalina.ant.ListTask" classpathref="catalina-ant-classpath"/>
    <taskdef name="catalina-reload" classname="org.apache.catalina.ant.ReloadTask" classpathref="catalina-ant-classpath"/>
    <taskdef name="catalina-findleaks" classname="org.apache.catalina.ant.FindLeaksTask" classpathref="catalina-ant-classpath"/>
    <taskdef name="catalina-resources" classname="org.apache.catalina.ant.ResourcesTask" classpathref="catalina-ant-classpath"/>
    <taskdef name="catalina-start" classname="org.apache.catalina.ant.StartTask" classpathref="catalina-ant-classpath"/>
    <taskdef name="catalina-stop" classname="org.apache.catalina.ant.StopTask" classpathref="catalina-ant-classpath"/>
    <taskdef name="catalina-undeploy" classname="org.apache.catalina.ant.UndeployTask" classpathref="catalina-ant-classpath"/>
  4. Finally you need a set of tasks that actually do the work. Although, as you can see above, there are a few tasks I only tend to use the following ones:
    <target name = "stop-webapp">
    <catalina-stop url="${tomcat.manager.url}"
    username="${tomcat.username}"
    password="${tomcat.password}"
    path="/${webapp.name}"
    failonerror="false"/>
    </target>

    <target name = "start-webapp">
    <catalina-start url="${tomcat.manager.url}"
    username="${tomcat.username}"
    password="${tomcat.password}"
    path="/${webapp.name}"/>
    </target>

    <target name = "undeploy-webapp">
    <catalina-undeploy url="${tomcat.manager.url}"
    username="${tomcat.username}"
    password="${tomcat.password}"
    path="/${webapp.name}"
    failonerror="false"/>
    </target>

    <target name = "deploy-webapp">
    <catalina-deploy url="${tomcat.manager.url}"
    username="${tomcat.username}"
    password="${tomcat.password}"
    path="/${webapp.name}"
    war="file:${war.file}"/>
    </target>
    tomcat.manager.url is the URL where Tomcat manager lives. This is another of the changes from Tomcat 6 to Tomcat 7. Usually this will be: http://:8080/manager/text.

    Tomcat.username and Tomcat.password are the user name and password for Tomcat manager.

    webapp.name is the name of the Tomcat application that you are deploying.

    war.file is the path the Tomcat application you are deploying’s WAR file.

    The stop-webapp task has the failonerror attribute set to false as on most occasions you don’t want the Ant build to stop if a Tomcat application you’re trying to stop isn’t running.

    I usually define all of these properties in a properties file that Ant can read. That way local settings can be picked up more easily if builds are run on different machines.

Saturday, 29 October 2011

Agile East Anglia

Inspired by the Extreme Tuesday Club (XTC) in London, Agile East Anglia's intention is to organise regular informal meetings for people new to Agile, Agile practitioners and Agile experts to meet, discuss ideas and network.

I'm hoping to arrange the first meeting in late November at the Coach and Horses on Thorpe Road in Norwich.

You can join Agile East Anglia here.

Thursday, 22 September 2011

Edward Jeremy Paul Grenyer

Date: Tuesday 20th September 2011
Time: 6.34pm.
Weight: 7lb 1oz

An Introduction to the WPF with the MVVM - Part 2

Originally published in CVu.

In part 1 of An Introduction to the Windows Presentation Foundation with Model-View-ViewModel I introduced the Canon application. I used it to introduce you to simple WPF UI development and the Model-View-ViewModel pattern including simple binding and commands.

Part 2 is focused around making the GUI look more aesthetically pleasing and introducing menus and tool bars and demonstrating system commands. I'll start off by introducing images.

Read More

Parts 1 & 2 combined can be found here.

Clean Code

by Robert C. Martin
ISBN: 978-0132350884

I knew this was going to be an excellent book from the moment I heard Uncle Bob describing his ideas of Clean Code at his key note at an ACCU conference. I bought the book there and then, but didn't start reading it until a couple of years later. More recently I got it signed by Uncle Bob at Skillsmatter. After just a few pages it propelled itself into my top three books every programmer should read (behind Kent Beck's Test Driven Development and The Pragmatic Programmer by Andy Hunt & David Thomas) and at the end it's still there.

The chapter on comments is worth the price of the book alone. I have worked in places over the last few years, where comments have been encouraged to explain the code, rather than writing code that explains itself. Another great chapter is the one on functions and the advice to keep them small is especially good and compelling. As I look back over the table of contents now, every chapter that describes how to improve an aspect of code is an absolute mine of good advice.

The final few chapters contain a number of refactorings. One on an application from the ground up and the others on existing code written by other people. This is the only place where the book got gratuitous and I must admit I skipped most of the final refactoring.

The final chapter is a summary of the advice given in the rest of the book and something I will find myself referring to again and again.

If you've read Test Driven Development and The Pragmatic Programmer, make sure you read Clean Code next.

Wednesday, 7 September 2011

Our House Is For Sale (Again)

3 bedroom town house for sale
Marauder Road,Old Catton,Norwich,NR6

MODERN 3 story home in Catton which features living room with Juliet balcony, separate dining room, kitchen/breakfast room, downstairs cloakroom, 3/4 bedrooms with en-suite shower room to master, bathroom, gardens, parking & garage. CALL LINK UP PROPERTIES ON (01603) 76 40 40 TO VIEW.

See this property on rightmove.co.uk

Wednesday, 31 August 2011

C# In Depth

Jon Skeet
ISBN: 978-1935182474

Let's get one thing straight, every single C# developer with a working knowledge of the language should read this book. I picked it up because it had been three years since I'd written any C# (I'd been doing Java) and back then all I had exposure to was version 1.1. I knew nothing of var, LINQ, Lambdas, extension methods or dynamic typing. I guessed a little about generics from my Java knowledge. I've read the book and now I know about all of them. Of course I don't know everything about all of them but I know enough to make use of them. If I went back and read the book again and again I would increase my knowledge of these features with each read.

This is not an introductory text. The book starts off with a a brief tour of C# 1.1. It then goes through all of the recent versions, 2.0, 3.0, 3.5 and 4 introducing most of the new features as it goes. It does what it says on the cover, it goes into each feature in depth. This is both the books strength and its weakness.

There is so much information in here that at times it is very heavy going. I will admit that I skipped a few sections when I felt that I knew enough and knew I could go back to it at any time. If I'm brutally honest, I feel that this book could be pruned quite a bit and still be in depth. Alternatively, maybe a text that gave an overview of the various features with some examples would have been more suitable for me.

Jon Skeet is clearly a C# junkie and very passionate about the language. Jon, you'll be glad to hear it does all make sense!

Wednesday, 17 August 2011

Pragmatic Version Control using Git

Travis Swicegood
ISBN-13: 978-1934356159

I was an early adopter of Subversion after having used CVS for a little while. I've come rather late to the Git party and I wanted a book that would give me a quick, yet solid, introduction. Pragmatic Version Control using Git is just such a book. I really like the Pragmatic Programmer books as they tend to be short and easy to read. They allow me to absorb a lot of information in a very short period of time.

The first thing that struck me was the brilliant simplicity of the example code. Many books on version control use Java as a language that is easily understood by most people. Even with Java you need a fair bit of code before you've got a program that does anything, even Hello, World! Swicegood uses HTML as his example code. This is perfect because everyone can understand it easily and you only need a little to do some interesting things. The HTML example is used throughout the book, in my opinion, very successfully.

Git itself took me a little by surprise. Having a local copy of the whole repository felt a little extravagant at first and it took me a while to get my head around the idea of having to add a file every time I want to commit it, even if I've committed a previous revision. However, Swicegood explains how and why you do both of these very well and now I see the benefit of local copies of a repository and having a staging area.

Branching is key to Git and Swicegood explains it in a lot of detail. The book closes with a chapter on Subversion and CVS integration and migration with Git and a chapter on setting up a Git server. The only disappointment for me was the sparse descriptions of GUI clients. I am totally addicted to TortoiseSVN and would have liked to have seen a Git equivalent explained in some detail.

Available on the Kindle here.

Thursday, 11 August 2011

Terminal World

by Alistair Reynolds
ISBN-13: 978-0575088504

I waited a long, long time for Terminal World. Even though it came out for the kindle at around the same time as the hardback, I had a feeling the price would come down at the same time as the paperback release. It was worth the wait, as a week after the paper back release the kindle version halved in price.

I'm afraid it's the same old story (no pun intended) with Alistair Reynold's post Revelation Space work. It lacks the depth and breadth and just isn't as good. And like House of Suns and Pushing Ice it sets the scene for a sequel, but you're left wondering if a sequel will ever materialise.

I did, however, love the characters in this book, especially Meroka. She was a real, down to earth, tell it like she sees it kind of a girl. If I met her on a dark night, I would want to be on her side! The main character, Quillion, who started off looking like he was going to be a weak, weaselly sort of a person turned out to be really strong. I think the book could have explored his past a bit more.

Parts of Terminal World really did have me gripped. The climax was a little disappointing and lacked Reynold's usual attention to detail and complexity. It's almost as if he got bored and didn't follow it through properly. The actual theme that was played out did take me by surprise, I still came away not feeling I fully understood everything. Maybe that was the idea?

I believe Reynold's next book will be for children. I'll still read it, but I imagine it'll be quite different. Hopefully still dark and full of space opera though.

Monday, 8 August 2011

An Introduction To Test Driven Development

Originally published in Overload 104

There are a lot of introductory articles for Test Driven Development (TDD). So why, might you ask, am I writing yet another? The simple answer is because I was asked to by Allan Kelly who wanted a piece for a small book he gives to his clients. I was happy to oblige, but writing about TDD is difficult. In fact if Allan hadn't wanted an original piece he could print as part of his book I would have suggested he just get a copy of Test Driven Development by Kent Beck. The main difficulty is coming up with a suitably concise, yet meaningful, example and Beck has already done this.

Allan was also quite keen for me to publish elsewhere, so I chatted the idea over with Steve Love, the editor of the ACCU's CVu magazine to see if he thought the readers would be interested in yet another TDD article. He said they probably would be as long as I thought carefully about how I wrote it. I thought this over for a long while. The majority of introductory TDD articles, at least the ones I have read, focus on unit testing. A recently completed ACCU Mentored Developers project read through Growing Object Orientated Software Guided by Tests by Freeman & Pryce. They focus on starting a simple application with acceptance tests and only writing unit and integration tests when the level of detail requires it or the acceptance tests become too cumbersome. However, it is a big book, so I decided to try and condense what I saw as the most important points into an introductory article and this is what you see before you. I hope you find it as useful and fun to read as I did to write.

Read more here.

Friday, 5 August 2011

R.I.P Andrew 'Mac' McDermott

The first time I encountered Threshold was at the first (of only two) ProgPower UK in 2006. I thought they were good and bough all their stuff. They turned out to be fantastic and Andrew 'Mac' McDermott's voice was just incredible. Unfortunately that was to be the only time I would see Threshold with Mac as he left the band shortly after the release of Dead Reckoning. It was a double shame as my wife and I had planned a short honeymoon so that I would be back in time to see them play in Nottingham at Fire Fest.

I found out yesterday that Mac died on 3rd August 2011. It's a real shame. Although it was highly unlikely I would see Mac sing again with Threshold, I had hoped for plenty more material with his other projects and maybe even to see him live.

He and his voice will be missed.

http://rememberingandrewmacmcdermott.webs.com/

Wednesday, 3 August 2011

Russel Winder: You Need To Know Python

Skills Matter Tuesday 2nd August

As I've said before, I love seeing Russel speak. He was on form again tonight, despite his migraine. One of the reasons I like seeing Russel speak is his sense of humour. Although, there is always a sensible and serious message behind it.

Tonight I think the message was really that knowing multiple programming languages and paradigms makes you a better programmer in all of them. The reason Russel chose Python is that he clearly has a deep fondness for the language. It has always appealed to me, so much that I write acceptance tests for my .Net applications in IronPython.

Harking back to Uncle Bob's talk a few weeks ago, Russel started with a whirlwind tour of programming languages through time, starting with FORTRAN through to the creation of C and the world domination of C++ that was eventually, according to Russel, killed off by Java. I'm not sure I agree with Russel here. I suspect what he actually means is that within academic institutions Java took over from C++ on computer science courses. I was certainly still programming in C++ in 2006 and didn't switch to Java until later. Conspicuous by their absence all the way through, were all the Microsoft languages. Russel clearly isn't a fan. Last came all the new dynamic languages such as Ruby and Clojure. Where was Groovy, Russel's favourite, I hear you ask? It was in the mix too. Unusually Russel only mention Groovy a couple of times tonight. The focus, as expected, was very much Python.

Then we got into the heart of the presentation and Russel explained his thinking and delivered his message that knowing multiple programming languages and paradigms makes you a better programmer in all of them.

In the final part of the talk Russel examined some of latest features of Python, including with, its take on C++'s RAII. I am almost entirely unimpressed with garbage collected languages versions of RAII. So much so I'm going to write a blog post. Watch this space. Finally he discussed one of the most important issues of our time, concurrency and parallelism. Python is unprepared, but it's being worked on.

The video of Russel's talk is link from his blog here.

Saturday, 30 July 2011

Agile Cambridge: Creating a Walking Skeleton from Scratch

11am Thursday 29th December 2011

Come and see me at Agile Cambridge.

Session

Starting with an (almost) clean IDE Paul will develop a Walking Skeleton.

The walking skeleton was described by Alistair Cockburn as "... a tiny implementation of the system that performs a small end-to-end function. It need not use the final architecture, but it should link together the main architectural components. The architecture and the functionality can then evolve in parallel." It is also one of the theme's in Freeman & Pryce's Growing Object Orientated Software Guided by Tests.

In this session Paul will start with an (almost) clean IDE and develop a walking skeleton for a simple application and demonstrate how Test Driven Development (TDD) can be used even at the system level to test features.

Profile

Husband, father, software consultant, author, testing and agile evangelist.

Paul has been programming in one form or another for over 20 years and has been involved in building agile teams since 2007. After several years of C++ and a very happy period using Java, Paul is now developing predominantly in C#.

Paul has worked in industries as diverse as marking machinery, direct mail, mobile phones, insurance and Internet TV. He is currently contracting at an investment bank at Canary Wharf.

When he's not programming or chasing his 2.5 children, Paul thoroughly enjoys science fiction, heavy metal and cycling.

Friday, 22 July 2011

Mocking C++

This month’s ACCU London was at 7City to hear Ed Sykes tell us about a couple of C++ mocking frameworks, MockIt Now and HippoMock. Ed is a very relaxed, confident speaker and the code and demonstrations he used were simple, straight forward and easy to understand. I mostly came a long to meet Ed as he’s an excellent contributor to the ACCU and specifically the Mentored Developers projects.

Ed obviously hit a chord with the audience and there was plenty of interaction and question asking. There were even a few tangents that Ed handled brilliantly. It looks like both of these frameworks use quite a bit of compiler magic and function pointer repointing, along with macro magic to achieve in C++, what is easily achieved with reflection in the likes of Java and C#.

Following the short presentation there was a long discussion on the more general topic of mock objects. Even though I haven’t used C++ for a little while, this presentation was absolutely fascinating and I will definitely be using a mock framework on my next C++ project.

Wednesday, 20 July 2011

Behavior Driven Development

While collaborating on a new article I was recently pointed in the direction of Behavior Driven Development (BDD) by Chris O’Dell. I only thought I had a vague idea of what it was before and I got so absorbed in Behavior Driven Development on Wikipedia and Dan North’s Introducing BDD today that I missed my stop on the tube. I never miss my stop on the tube!

There are two main points that stood out for me.

I usually develop software inside out. Start with the model and then add the user interfaces on top. Dan North tells us that the first thing that we should do is get the user interface going and then show it to the customer/user to get immediate feedback. This is actually far more sensible as the user interface is what the users see and use, so they can tell you if it’s right or how it needs to be changed. Then you can develop the model to suit, rather than the other way around.

For while now I have been looking for a good way to record acceptance criteria with user stories and I think I’ve found it. Dan gives and example of an ATM:

To illustrate, let’s use the classic example of an ATM machine. One of the story cards might look like this:

+Title: Customer withdraws cash+
As a customer,
I want to withdraw cash from an ATM,
so that I don’t have to wait in line at the bank.

So how do we know when we have delivered this story? There are several scenarios to consider: the account may be in credit, the account may be overdrawn but within the overdraft limit, the account may be overdrawn beyond the overdraft limit. Of course, there will be other scenarios, such as if the account is in credit but this withdrawal makes it overdrawn, or if the dispenser has insufficient cash.

Using the given-when-then template, the first two scenarios might look like this:

+Scenario 1: Account is in credit+
Given the account is in credit
And the card is valid
And the dispenser contains cash
When the customer requests cash
Then ensure the account is debited
And ensure cash is dispensed
And ensure the card is returned

Notice the use of “and” to connect multiple givens or multiple outcomes in a natural way.

+Scenario 2: Account is overdrawn past the overdraft limit+
Given the account is overdrawn
And the card is valid
When the customer requests cash
Then ensure a rejection message is displayed
And ensure cash is not dispensed
And ensure the card is returned

Both scenarios are based on the same event and even have some givens and outcomes in common. We want to capitalize on this by reusing givens, events, and outcomes.


Of course there is a lot more to BDD, than I have described here, but these are the inspirational particles for me.

Friday, 15 July 2011

An Introduction to the WPF with the MVVM - Part 1

After three wonderful years working with Java I am back in the C# arena and amazed by how things have changed. When I was working with C# previously it was with .Net 1.1 and as I return .Net 4 is ready to go. I started a new contract and my client suggested that to get ahead of the game I should learn Windows Presentation Foundation (WPF), the latest Microsoft framework for creating Windows desktop (and web) applications. It replaces the likes of Windows Forms on the desktop. Two of the major features of WPF are that it is rendered entirely on a computer's graphics card and separates presentation from presentation logic.

Manning is my preferred technical book publisher, so I bought the PDF version of WPF In Action with Visual Studio 2008 and read it on my Kindle. It is a great introduction to producing Graphical User Interfaces (GUIs) with WPF, but I later discovered that although Model-View-ViewModel (MVVM) is covered, the detail is not great. The MVVM pattern is similar to Martin Fowler's Presentation Model, but where the presentation model is a means of creating a UI platform-independent abstraction of a view, MVVM is a standardised way to leverage core features of WPF to simplify the creation of user interfaces. Fortunately there is a great MSDN Magazine article called WPF Apps With The Model-View-ViewModel Design Pattern that explains it simply and in a fair amount of detail.

To demonstrate WPF with MVVM I am going to incrementally develop a small application which allows the user to search an archive of books. The application is called Canon and the source code is available for download from my website. I developed Canon using Visual Studio 2010 and .Net 4, but WPF applications can also be created with Visual Studio 2008 and .Net 3.5. I have assumed that the reader is following along.

Read more. Originally published in CVu.

Canon-0.0.1.zip

JVM Cloud Platforms

Tonight kicked off with the usual high quality lightening talks that I have come to expect form the London Java Community.

The two main presenters spoke individually about the cloud solutions that their individual companies offered. I know little to nothing about cloud computing. The emphasis was centred around Platform As A Service (PaaS). It appears that most of the major players (Amazon, google, etc) do not provide a private PaaS for testing and development. I find this astounding, despite the fact that I have worked with at least one major vendor who makes it very expensive to have a development environment, but at least it was still possible.

The stronger of the two systems described seemed to be the offering from SpringSource. Peter Ledbrook (Grails Advocate and ACCU Mentored Developers mentor) is a very interesting speaker. He has clearly been bitten by live demos not working in presentations before and, alas, he was bitten again tonight. Although, the previous speaker also had a problem with his live demo.

The more I hear about cloud computing, the more interested I get. With the two offerings this evening there is the opportunity to try it for free to get a real feel for it. However, I just don’t have a sufficient interest yet or a cloud suitable application to make it worth the while. Maybe my next contract.

You can see the video here.

Thursday, 14 July 2011

One Test Or Two?

Paul Grenyer & Chris O’Dell

"I know what you’re thinking: “Is that two tests or only one.” Well, to tell the truth, in all this agility, I’m not sure myself. But this is Test Driven Development, the most power development technique in the world, and could give you clean code, you’ve got to ask yourself one question: Do I feel expressive? Well, do ya, punk?"<

Paul: I have a Windows Presentation Foundation (WPF) application that loads a list of widget names from a database and uses them to populate a drop down box. There is no default widget, so the user must select one from the list and click the load button to load it. The behavior is such that before a widget name is selected the button is disabled and cannot be clicked.

One pattern often employed in WPF applications is Model-View-ViewModel. The view model can use variations of the Command Pattern for processing commands from and giving feedback, such as the enabled state of a button, to the View. MVVM is intended to give separation between a view and its logic. Therefore the view model is usually devoid of User Interface (UI) code and easy to instantiate and run unit tests against.

I have a unit test that instantiates a view model and checks that the load command cannot be fired until a widget name is selected. A simplified version is show below, without the view model instantiation:

public void testThatExecuteIsOnlyPossibleIfNameIsSet()
{
Assert.IsNull(model.Name);
Assert.IsFalse(model.CanExecute());
model.Name = "Something";
Assert.IsTrue(model.CanExecute());
}

Recently I have also been involved with the ACCU Mentored Developers project based around Growing Object Orientated Software Guided By Tests by Steve Freeman and Nat Pryce. In this book they write a lot about the naming and granularity of tests. So I posted the above code to the list and asked what the project members thought: “Should the above test be one test or two?”.

Chris: Without blinking I immediately replied that the above should definitely be split into two distinct tests so that a failure would be obvious from the test name. The above test has two asserts and as such either of these could fail.

Paul: Chris, and all the others who replied are of course right on the money (no one suggested it should only be one test), but something didn’t sit quite right with me. In this small example the extra code of two tests is not very much: the method definition, a pair of curly braces and some spacing. The problem for me is that test classes should not be treated that much differently to normal classes and any class with with a large number of methods becomes difficult to maintain and difficult to even to navigate. Although modern IDEs do make this easier with regions (C#) and code collapsing (Eclipse).

Chris: I firmly believe that it is worth the extra code - as many others also remarked, the five minutes now and extra curly braces could easily save twice that if you need to hunt down a related bug in future.

I went on to explain that in terms of application logic the two scenarios “with a name” and “without a name” are expected to be mutually exclusive and the two tests will ensure this by isolating each scenario and addressing them individually - with explicit test names.

In regards to the large classes this can be tackled by breaking your tests down into smaller classes, generally per scenario. For example, group all of the positive “happy path” tests together into one class and all the negative, error handling tests into another class and store both classes in a folder given the name of the class under test.

Paul: Again, Chris is of course right. Although the implication that a test method should only have a single assert is a whole other discussion.

Then Nat Pryce came along with another suggestion altogether:

“To really play Devil's advocate, I think there should be THREE tests!

1. The model initially has no name
2. The model cannot execute when it has no name
3. The model can execute when the name has been set.

You could squeeze that into two:

1. The model initially cannot execute
2. The model can execute when the name has been set

But I think the state transitions and constraints are clearer with three tests.”


Even with there now being the extra code for three functions, rather than one, this is of course the answer. It even satisfied the idea of one assert per method. The most difficult idea for me was not testing preconditions specific to a test if they were already tested in a another test .I have consequently modified my way of thinking and a lot of my test code.

Originally published in CVu July 2011.

Wednesday, 13 July 2011

The Last Programming Language

Tonight was mostly about entertainment and Robert C. Martin had me in stitches for most of the evening. He started off, as I gather he often does, by seeing who in the room could recite PI to any number of decimal places and how he lost a PI off to Herb Sutter.

Throughout his talk Uncle Bob mentioned most of the languages and paradigms of the last 60+ years and gradually brought us to the idea that nothing much that was really new has come about since around 1965. He went on to tell us that he thought that programming would converge into a single language. He even told us what that language would be, but I'm not going to spoil his surprise.

If you ever get the chance, go and listen to Uncle Bob! It's 100% geeky fun with a serious message. And I got my copy of Clean Code signed.

See the video here.

Sunday, 10 July 2011

Progressive Psychedelic Pulp

Hyde Park, Sunday 3rd July 2011.

I was only meant to be playing the role of taxi driver, but after most of the party dropped out, my wife talked me into going to Hyde Park to see Pulp with her. I wasn't really looking forward to it as I was expecting a 90 minute set with probably only a couple of songs I knew. I couldn't have been more wrong! There were only a couple of songs I didn't know!

We got to the festival just in time to catch Grace Jones. The best that can be said about her is that she has a great voice, but bad songs. She finished with a Roxy Music cover of Love Is The Drug and Slave to the Rhythm, so it wasn't all bad.

By the time Grace left the stage we'd been allocated some seats. Sometimes having a pregnant wife is an advantage!

I really wasn't expecting Pulp to do the big arena/festival thing either, but they did. They started with a big black curtain in front of the stage onto the back (stage side) of which they shone a lazer. A camera replayed what the lazer was writing to the audience via the large screens at the side of the stage: "Do you remember the first time?", "Are you ready?", "Again, are you ready?", etc. Then the curtain fell to the sound of streamers exploding into the crowd and there was Jarvis et al ripping through Do You Remember The First Time. From then on it was hit after hit including Sorted For Es And Whiz and Disco 2000.

I thought Jarvis would be too "cool" to stand on the monitors, but all he needed was a bass guitar and he could have been Steve Harris. He charmed the audience after every song proving what a great performer he is. The band was note perfect and the quality of the PA surprising.

Towards the end of the set Pulp did a couple of songs from the album that apparently followed Different Class. I could only describe them as Progressive Psychedelic Pop and really quite good, further proving what talented musicians they are. Then there was just time for a couple more hits, before the band, sensibly, didn’t waste time going off prior to an encore. Of course the final song was Common People, preceded by by a teasing description of St. Martin’s college form Cocker.

Was I impressed? Yes! Was I pleased I’d gone? Yes! Would I go to see Pulp again? Maybe.

Transformers: Dark Side of the Moon

We enjoyed the first transformers film, but didn't think much of the second. However the trailer for Transformers Dark Side of the Moon was excellent. The first ten minutes of the film, which featured the first moon landing, was superb. Then the film fell apart. It's not just that the Witwickey character is rubbish or the fact that the Autobots are a bit soft, but the language, the sex and the violence is way too much for a 12A.

Having seen the first two films we thought we were in safe territory. We'd taken our son for his 8th birthday, along with a friend, and my wife and I were wincing most of the way through. The language was very frequent and gratuitous, including at least one use of the F word. There was a lot of flesh on show in the opening scenes with Whitwiky. Once the film got going, there was a lot of gratuitous violence, including Transformers machine gunning humans in an office block through the window and Transformers vaporising humans leaving only a skull rolling away. What were the classifiers thinking?

As well as language, sex and violence the film just seemed to go on forever. There was a plot discrepancy where Megatron cuts Sentinel Prime's head off and a few minutes later it's on again when he fights with Optimus Prime.

Don't take your children to see this film.

Thursday, 7 July 2011

It's Always Nice To Get A Mention...

Please go along and read this new blog post by Agile Coach Rachel Davies on When To Write Story Tests.

Saturday, 2 July 2011

Threshold @ The Peel 2011

Threshold are simply amazing. Ok, so they are my favourite band, so I may be a little biased. I have seen them six times now, almost as many times as I've seen Terrorvision and the Wildhearts, and they get better every time.

Threshold should be playing places much, much bigger places than The Peel in Kingston, but I am so glad they aren't. In these tiny venues you can get right up and personal with the band. Not only that, but the band walked into the Pizza restaurant my friends and I were enjoying before the gig, Damian Wilson was on the door talking, as he always is and the remainder of the band were reportedly in the bar signing stuff after the gig.

With no support they played a stonking two hour set with something from every album except Psychedelicatessen:

Slipstream
The Ravages of Time
Long Way Home
The Destruction of Words
Hollow
Sanity's End
Falling Away
Clear
Ground Control (acoustic version)
Pressure
The Art of Reason
This Is Your Life
Pilot in the Sky of Dreams
Mission Profile

Encore:
One Degree Down
Light and Space

Damian Wilson only sang originally on two of the songs in the set (Sanity's End and Clear), but he makes every song his own. At the end of a Fish gig I look forward to him pirouetting into the crowd during External Exile. Damian must have been into the crowd four or five times throughout the set, mostly due, I imagine, to the lengthy instrumental breaks in most of the songs. Forget Freddie Mercury, Damien Wilson is the ultimate frontman and his charismatic ability as frontman is second only to his incredible singing ability. It's going to be interesting to hear his vocals on a new Threshold album for the first time since 1998's Extinct Instinct.

I could listen to Karl Groom play guitar all night! In my opinion he is second only to David Gilmour, but he looks like someone's uncle! In fact all of the band and a lot of the crowd are firmly into middle age. Does it show in the heavy progressive metal they play? Does it stop the crowd being louder than the PA? Of course not!

I can't wait for the new album and to see them play again. If you only every see one progressive metal band, make sure it's Threshold!

Tuesday, 28 June 2011

Fallen Dragon

by Peter F. Hamilton
ISBN: 978-0330480062

This is the first Peter F. Hamilton book I have read. It's a big book and proper science fiction. I liked it a lot. In fact bits of it I thoroughly enjoyed. However, it's nothing special and really quite predictable. Although I didn't see the final little twist right at the end coming. From what I had heard I expected a bit more from Peter F. Hamilton, but I will certainly be reading his other books.

The characters are superb. I really related to them, especially the young Laurence when he met, loved and lost Roslyn. I spent the whole book wanting him to get her back. I won't tell you if he did or not. I found Laurence's disgust at the idea of real food interesting on a couple of levels. First there is all the aversion to processed food in modern society and then I remembers the children in James Follett's Earth Search entering puberty when they finally stopped eating the processed food provided by the Angels.

Wednesday, 22 June 2011

Spring Roo at Skills Matter

I've just got back from a fantastic presentation on Spring Roo from Jan Machacek of Cake Solutions. It was hosted at Skills Matter by Barry Cranford of the London Java Community. I came away totally understanding what Spring Roo is for.

In a few words, it's code a generator that gives you a boost when creating Java and Spring MVC based web applications. It uses a lot of Aspect Orientated Programming (AOP) to take away a lot of the boiler plate code, such getters and setter on beans and persistence, that are required for CRUD web applications. If, after the application is completed, you want to stop using Sprig Roo, you can. If you want to keep using it to generate more of the application, you can and it examines the code every time you build to see if it can generate more helpers from your changes. It's not a silver bullet or a golden hammer thought, it's another tool in a Java web application developers arsenal.

One draw back for me is that Spring Roo requires Maven (quite possibly one of the roots of all evil) and I don't yet know know enough Grails to know if Spring Roo provides greater advantages for web development.

Jan Machacek is a excellent speaker, very clear and enthusiastic as well as knowledgeable without being arrogant. He clearly understands Spring Roo inside out and was able to answer all of the questions asked. The only frustrating thing was that every time I thought of a question, it was answered a few slides later.

You can see the video here.

Thursday, 9 June 2011

Working Effectively with Legacy Code Project


The ACCU Mentored Developers have recently started a project based on Working effectively With legacy Code (ISBN: 978-0131177055) by Michael Feathers. The project members are reading about a chapter a week, starting on Monday 13th June 2011. Each week a project member will publish a review of a chapter and the group will discuss the chapter and the review on an email distribution list. This all happens under the watchful eye of the book's author, Michael Feathers.

The project is only open to ACCU members, but you can join very cheaply and there are other benefits including an ACCU Conference discount and journals. The project schedule can be viewed here and project distribution list is here.

Tuesday, 7 June 2011

Execute Around Exception

I have a lot of UI controller code that looks like this:

try
{
// Do something that might throw is is probably a single line of code
}
catch (Exception e)
{
// Notify the user of the problem.
}

This is 8 lines of code for a single line operation. The common code that notifies the user of the error, commonly just a message box, can easily be refactored into a single method. The problem is the try/catch block. So I started wondering if I could reduce it somehow. I would be so much nicer if I could write:

ExecuteSafely(delegate
{
// Do something that might throw is is probably a single line of code
});

where ExecuteSafely takes care of the boiler plate code. I started playing around with Execute Around Method ideas and came up with this:

public class ExecuteAroundException
{
private readonly Action<Exception> exceptionHandler;

public ExecuteAroundException()
: this(delegate { })
{
}

public ExecuteAroundException(Action<Exception> exceptionHandler)
{
this.exceptionHandler = exceptionHandler;
}

public void ExecuteSafely(Action action)
{
try
{
action();
}
catch (Exception e)
{
exceptionHandler(e);
}
}
}

The default exceptionHandler does nothing. It just swallows the exception. The chances of you wanting to use it are therefore slim. However you can provide a delegate that handles the exception:

ExecuteAroundException x = new ExecuteAroundException(delegate(Exception e)
{
// Notify the user of the problem.
});

And then you can use it like this:
       
x.ExecuteSafely(delegate
{
// Do something that might throw is is probably a single line of code
});

The only two scenarios where this is worth while is when the ExecuteAroundException instance is created once at class scope or created in a factory method. Otherwise you end up with almost as much code.

Monday, 6 June 2011

Cerebral Bore

I buy a lot of music so I don’t often get a chance to blog about it. However Cerebral Bore are really something else. Hailing from Scotland and with a singer from Holland they’re the best death metal band I’ve discovered since Annotations of An Autopsy. I originally read about them in Metal Hammer, where they were described as concerned no one would take them seriously as they are a death metal band with a female vocalist. After the success of Arch Enemy I really couldn’t believe it would be a problem, so I bought their debut album Maniacal Miscreation and I wasn’t disappointed.

Tuesday, 31 May 2011

Growing Object-Oriented Software, Guided by Tests

by Steve Freeman and Nat Pryce.
ISBN 978-0321503626

I'll cut straight to the chase: This is a great book! In fact I'd put it second, behind Test Driven Development by Kent Beck, on my must read list for developers. Testing is so important and while Unit Testing is becoming mainstream, many are failing to take the next next few steps to integration and system (end-to-end) testing. This book tells you why you should and shows, with practical examples, how to get started.

Growing Object Orientated Software Guided by Tests was the first place I read about the Walking Skeleton. Originally described by Alistair Cockburn, this is a technique I've been using for the last few years and didn't realise there was a name for. The Auction sniper example that covered by the middle chapters introduces not only testing techniques, but lots of useful and practical lessons about good design. The later chapters discuss improving your tests, including readability. The final two chapters cover testing threaded code and asynchronous code. Some of the ideas presented here were new to me and would have have been very useful refactoring exercises for some projects I used to work on.

If you want to develop higher quality, robust software, read and apply the lessons in the book.

Warning: The code examples in the Kindle version of this book are difficult to read and there are a few misprints compared to the paper version.

Monday, 30 May 2011

Triumph TR7 V8 Forsale

Today is a dark day. My pride and joy is forsale:

http://tinyurl.com/3o37rdy

Triumph TR7 drop head in British Racing Green. Converted to 3.5 litre V8 using a Rimmer Brothers Kit and SD1 engine. Engine modifications include Carter downdraft carburettor (Similar to Webber) and a 4:2:1 twin stainless steel exhaust system (beautiful V8 sound). 15inch alloy wheels, including spare, with Michelin Pilot 205/50 tyres with plenty of tread. Brakes have been uprated with front ventilated discs and 4 pot callipers. The suspension has also been uprated. Tow bar with single socket electronics. Bee Security category 2 immobiliser. Panasonic CQ-FX321N stereo radio with 6 disc CD changer.

The car is in generally good condition but has a few quirks and some surface rust as one would expect from a car of this age. The worst rust is shown in one of the photos. The drivers seat is in poor condition (see photo) but there is a spare driver’s and passenger’s seat to go with the car. The high speed setting for the wipers does not work but there is a replacement wiper motor included. The indicated mileage is 8950 which is believed to be the mileage since the V8 conversion, but this cannot be confirmed. The car is perfectly driveable but could do with some TLC.

The TR7 is a very underrated British sports car. With the original 2.0 Litre engine the performance was unimpressive but the torque of the V8 engine really brings the TR7 alive with the modified suspension and braking system matching the increased performance. This is a real opportunity to obtain a classic high performance convertible at a budget price.

Inspection welcomed and a test drive can be arranged with proof of insurance cover.

The car has been advertised elsewhere and therefore may be withdrawn before the end of the auction.

Monday, 2 May 2011

Afterglow by Kevlin Henney

We all know Kevlin Henney from his technical writings, so I was keen to see what sort of fiction he might write. Before I read it, and even now, I had no idea of what the guidelines set for this short story were, but I was hoping for some science fiction. There wasn’t any, but it was still good.

The subject matter of Afterglow is a little on the dark side and like so many good stories, I had to read it a couple of times to really understand what it was about, who the person telling the story was and what situation they found themselves in now. Along with all the obvious emotion and feeling there is still a slight technical edge in certain places.

Personally I’m looking forward to the next, hopefully longer, piece.

Sunday, 24 April 2011

Market Forces

Richard Morgan
ISBN: 978-0575081260

I did not like this book at all! Which is very disappointing because, despite some slow parts, I've loved everything else I’ve read by Richard Morgan. There were a few good sections, but the book never got going, there was no plot, the climax was quick and disappointing and I had a feeling the whole way through that I was missing something. Maybe I was. As I've implied before, I like my science fiction novels to have science fiction in them and it was mostly missing here. And of course Lackenheath is in Suffolk, not Norfolk. I'm told Black Man is very much better and I won't let one poor story put me off Richard Morgan.

Wednesday, 13 April 2011

Our House is Forsale

3 bedroom town house for sale
Marauder Road,Old Catton,Norwich,NR6

MODERN 3 story home in Catton which features living room with Juliet balcony, separate dining room, kitchen/breakfast room, downstairs cloakroom, 3/4 bedrooms with en-suite shower room to master, bathroom, gardens, parking & garage. CALL LINK UP PROPERTIES ON (01603) 76 40 40 TO VIEW.

See this property on rightmove.co.uk

Dive Into Python

by Mark Pilgrim
ISBN: 978-1590593561

I used to do the odd bit of Python programming a few years ago and as part of a recent position. I hadn't done any for a year or more and when I came to pick it up again, to write some acceptance tests for a .Net command line application, I found I could hardly remember anything. So I asked some people about good refresher books. Dive Into Python came dubiously recommended.

Dive Into Python is a great book, once you get used to the chatty style and things like “...actually, what I just told you was a lie. The truth is....” and “....you didn't really think that did you? Go and sit in the naughty corner!” Each chapter builds on the next and has copious amounts of examples, all of which are explained in detail line by line. The domain of all the examples are simple and extremely well thought out.

The web service chapters aren't really about web services, but web service clients. I found this rather disappointing. I skipped the chapters on XML manipulation and regular expressions. The chapter on dynamic functions says that you should read the chapter on regular expressions first, but there's really no need as all the regular expressions are explained in detail. The unit testing chapters are very good. The functional chapter is really just an extension of the unit testing chapters. Following the optimisation chapter, the final 20% of the book is appendices.

Dive into Python is available for free here.

Monday, 4 April 2011

Nested Types

The ideas behind encapsulation and abstraction, to a certain extent, are about you as a developer keeping control of your code and how others use your code. For example if there's an operation in your library that would have bad consequences, you make it difficult or impossible to do.

Developers being able to understand your code is also very important. Putting things in context makes understanding your code easier.

What's my point? Nested types, enums, constants etc, not only help you control the way your code is used, they also identify those nested things as belonging to the context of the class in which they are nested.

Friday, 1 April 2011

Firstborn: A Time Odyssey Book Three

by Arthur C. Clarke & Stephen Baxter
ISBN: 978-0575083417

I read the other two Time Odyssey books some years ago I seem to remember enjoying them more. It could be of course that since I've discovered Alistair Reynolds and Richard Morgan, Arthur C. Clarke's relatively soft style just doesn't cut the mustard.

I did enjoy this book. I also discovered I'd forgotten most of the story from the previous two. The story develops on three different fronts, Earth, Mars and Mir and I had trouble following the characters from one switch to the next.

Nothing very exciting happens throughout, but it does get better towards the end. In fact I couldn't put the book down for the last 80%. I'll still read Arthur C. Clarke and I do hope Stephen Baxter writes another in the time Odyssey series.

Friday, 11 March 2011

Woken Furies

by Richard Morgan

ISBN-13: 978-0575081277

I have read all of Richard Morgan's books in this series up to Woken Furies and this is the best yet. The characters are deeper and more intricate. The plot twists and turns and bubbles with the unexpected. There is more of everything that Richard Morgan does best. There is the odd slow patch as the pace is moderated towards the middle, but it soon picks up again. There are all sorts of questions that materialise throughout the book, some of which are not answered until the end. It takes some following, but is well worth it! I can't wait to read the next one.

Tuesday, 1 March 2011

Integration Testing A Java Enterprise Application Data Access Layer

Finding the best design approach is only part of the solution to writing an Enterprise Application. As with all software, the application must be tested. Unit tests are the first line of defence, but they only the units of the application individually. You also need to test how the units interact with each other and other parts of the application, such as the database. These sorts of tests are called integration tests.

Soon after I discovered unit testing I accidental discovered integration testing. I was writing a system that interacted with a database at just about every stage. So each of my tests would start by creating and populating the database. Then the tests would be run and afterwards the database would be torn down. Creating and destroying the database for each test ensured that it was always in a known state. It also meant that every test took a very long time to run. When I only had a handful of tests this was not too much of a problem. Once I had in-excess of a hundred tests it was a big problem! A general rule is that tests should take close to zero time to run, or people stop running them.

I started to think about how I could improve the performance of my integration tests. So I created a data access layer as is described in my article Data Access Layer Design for Java Enterprise Applications. This enabled my integration tests, which were only masquerading as unit tests, to become real unit tests as they could use a mocked-out data access layer, rather than a real database, there by reducing their run time to almost zero. However, I still needed to write true integration tests to test the data access layer itself. These tests still needed a real database.

Most of the time taken up in setting up and tearing down a database is in its creation and deletion. The actual insertion, update, reading and deletion of data is relativity quick. Most databases support transactions. Transactions prevent a unit of work from being committed to the database until it is completed successfully. If an error occurs part way through the unit of work the transaction can be rolled back and none of the work carried out is committed. If the unit of work is successful it is committed to the database in its entirety once complete.

This can also be applied to testing. At the beginning of an integration test a transaction is started. As necessary, data is inserted into the database and the tests run, which themselves may insert or remove data. Once the test is complete the transaction is rolled back and the database is returned to its original state before the tests. Even if the test fails, the transaction is rolled back and the database returned to its original state.

Once I discovered this I moved the creation of the database structure (the database itself, tables, views, stored procedures, reference data, etc) to my build script and started running my tests in transactions. This greatly improved the performance of my integration tests.

Read more...

Monday, 31 January 2011

The Last Theorem

by Arthur C. Clarke & Frederik Pohl

ISBN-13: 978-0007290024

I expect Arthur C. Clarke is turning in his grave. I've quite enjoyed some of his posthumous collaborations, but this novel is just plain bland. There isn't even enough tragedy to keep Steps happy, let alone the Begees and the two main tragedies are really quite sanitised and not that upsetting at all. This might be a good book for mathematicians, but there's precious little science fiction until the final third and even then not a lot. I did quite enjoy some of the politics and references to current events, such as Somali prorates, otherwise ignore this book. I won't be reading anything else by Pohl.

Sunday, 30 January 2011

ACCU Mentored Developers Project: Growing Object-Orientated Software, Guided by Tests

The ACCU Mentored Developers will soon be embarking on their next big project, a read through of Growing Object-Orientated Software Guided by Tests by Nat Pryce and Steve Freeman. This will differ slightly from the tradition project structure as there are no "items" or exercises. However, most of the chapters are only 10 to 20 pages long and can therefore be read and discussed as if they are items. We're hoping to read at a pace of 2 chapters a week. Each chapter will reviewed and summarised by an allocated project member and serve as a starting point for group discussion.

The project is open to all ACCU members. To take part, please sign up to the list at the link below and make yourself known:

http://lists.accu.org/mailman/listinfo/accu-mentored-growing

You can take part as a project member, who will be allocated at least one chapter to review or an observer, who doesn't review a chapter but is free to take part in the discussion. If you have an questions about the project, please feel free to email me.