Subscribe to
Posts
Comments

IETester

A colleague mentioned IETester today at work. In a nutshell it lets you test your website in multiple version of Internet Explorer on the same machine, no need for seperate VMs. It lets you arrange browsers side-by-side by dragging (ala Windows 7 and Chrome 2).

My notes from XP Day 2008

I was at XP day last week in London. I thought i’d log my notes here in no particular order.

From two sessions about Lean and Kanban - Flow and Cadence, and Using Lean to Evolve Out of Scrum

  • Think about Flow rather than batching to reduce risk and deliver value more quickly, if doing this highlights transactionally expensive procedures (e.g. release) then look to reduce that cost by eliminating waste or automating
  • Have checklist/ritual detailed about swimlanes describing entry criteria
  • Pull board items through the swimlanes rather than pushing them and have limits on the number of items in each swimlane. This highlights bottlenecks early and makes the team swarm around bottlenecks rather than generating more backlog
  • Karl Scotland showed this concrete example of how multi-tasking causes project delays due to context switching

One of the systems I work on contains several distributed processes communicating via Active MQ. Integration testing these components has proved unreliable and complex so I attended Testing asynchronous behaviour and got the following inspiration.

  • Testing asynchronous apps makes your unit test code messy and complex waiting for callbacks, state changes, etc. Instead wrap the asynchronous sections in an API to simplify your unit tests.
  • Abstract the messaging interface, implemented a threaded messaging solution and then test the distributed components in separate threads but in the same process space.

An interesting open space titled Why aren’t they typing more. This introduced the Japanese word Mu roughly translated as ‘To un-ask a question’. e.g. The question ‘Why aren’t they typing more’ (often asked when managers see developers pairing) is such a ridiculous question that the person asking needs to un-ask that question.

Portia Tung and Pascal Van Cauwenberghe hosted the Real Options Space Game. I’d not heard of Real Options before the game, but i’d played a previous game with them so I went along to discover more.

Portia writes

Real Options is a decision-making process for managing uncertainty and risk. It’s a simple and powerful approach that helps us make better informed decisions, as individuals and in groups, by understanding and responding to the psychological effects uncertainty has on our behaviour.

On the day I didn’t realise just how much we do this in everyday life. I’ve written more on this in a separate post.

I participated in a coding DoJo called ‘Dirty Jobs’ in which 15 of us paired to add a simple new feature to a (deliberately) complex, messy and untested piece of Java. This was interesting to see how many problems we could identify in the code, and how different people felt we should address the problem, ranging from ‘refactor to make testing possible’ to the diametrically opposed ‘test what we have then refactor’.

An enjoyable and worthwhile two days.

Real Options

After hearing about Real Options at XP day, a little example I thought through of how I unknowingly used the technique recently. From Portia,

Real Options is a decision-making process for managing uncertainty and risk. It’s a simple and powerful approach that helps us make better informed decisions, as individuals and in groups, by understanding and responding to the psychological effects uncertainty has on our behaviour.

Travelling to my parents at Christmas I’d decided the dates but needed to choose the method of travel.

  1. Book train ticket now with reservation.
  2. Defer booking train ticket until nearer the time, possibly no reservation
  3. Hire a car for the trip
  4. Book plane ticket
  5. Book coach ticket

These options present themselves as soon as i’ve decided my time off work but until I know the relative costs and availabaility of them I cannot make a decision. So I look online, find the costs, and I can add the relevant information.

  1. Book train ticket now with reservation - no reservations possible. Buying cost: £60, Exercise cost: £0, Expiry date: imminent
  2. Defer booking train ticket until nearer the time, possibly no reservation. Buying cost: £60, Exercise cost: £0, Expiry date: day before travel
  3. Hire a car for the trip. Buying cost: £150, Exercise cost: £80 (petrol), Expiry date: day before travel
  4. Book plane ticket. Buying cost: £150, Exercise cost: £0, Expiry date: imminent.
  5. Book coach ticket. Buying cost: £30, Exercise cost: £0, Expiry date: 3 weeks before travel

This information lets me rule out Option 1. Why book ticket now for the same cost and availability as Option 2? Option 4 has an imminent expiry date and with it’s increased cost it’s also ruled out. I also have a dislike of coach travel so I ruled Option 5 out despite it’s attractive price.

A week later I checked out the costs and availability of the remaining options. I also introduced travel time to the equation.

  1. Book train ticket now with reservation - no reservations possible. Buying cost: £60, Exercise cost: £0, Expiry date: imminent
  2. Defer booking train ticket until nearer the time, possibly no reservation. Travel time: 2 hours. Buying cost: £60, Exercise cost: £0, Expiry date: day before travel
  3. Hire a car for the trip. Travel time: 4 hours. Buying cost: £150, Exercise cost: £80 (petrol), Expiry date: day before travel
  4. Book plane ticket. Buying cost: £150, Exercise cost £0, Expiry date: imminent.
  5. Book coach ticket. Buying cost: £30, Exercise cost: £0, Expiry date: 3 weeks before travel

As these two options have the same expiry date I waited a little longer. A week later I checked prices and availability again.

  1. Book train ticket now with reservation - no reservations possible. Buying cost: £60, Exercise cost: £0, Expiry date: imminent
  2. Defer booking train ticket until nearer the time, possibly no reservation. Travel time: 2 hours. Some routes are beginning to have no availability. Buying cost: £60, Exercise cost: £0, Expiry date: day before travel
  3. Hire a car for the trip. Travel time: 4 hours. Buying cost: £220, Exercise cost: £70 (petrol got cheaper!), Expiry date: day before travel
  4. Book plane ticket. Buying cost: £150, Exercise cost £0, Expiry date: imminent.
  5. Book coach ticket. Buying cost: £30, Exercise cost: £0, Expiry date: 3 weeks before travel

Given this latest set of information made it easy for me to decide on Option 2 and I bought my ticket. Most of this happened automatically for me, and it probably does for you to. For example,

  • When buying clothes, you see an item you want but it’s the last on the rail. Maybe you hide it, or ask the assistant to reserve it for you. This pushes back the expiration date of the option allowing you to check other shops before making your choice. (Thanks to Portia for this example)
  • Deciding about eating that pizza at 1pm. Defrosting a frozen pizza will take 3 hours, so its buying cost is £3, exercise cost is £0, and the option has an expiration time of 10am. Ordering a take away will have a buying cost of £10, exercise cost of £0 and an expiration time of 12.30pm. The night before you know that waking up at 9am gives you both options, but waking up late reduces your options.

Interesting stuff.

Everytime I try and get Ayende’s NHibernate Query Analyzer to work I seem to encounter some weirdness. Here’s what I did to get it running this time.

  1. Download the version appropriate to your version of NHibernate. For me, that was 1.2GA
  2. Create a new app.config file, and into it place just the NHibernate configuration section and the appropriate settings. Note that when I tried it, NQA didn’t like the <hibernate-configuration> notation for the hibernate section, instead I had to change it to use the <nhibernate> notation.
  3. Load up NQA and start a new project.
  4. Add the app.config file you created and the assemblies which contain your embedded HBM files.
  5. Hit Build Project. IMPORTANT! If you see any errors, then quit NQA, fix the errors, and start again. If you leave NQA running and try again you’ll see the same error message as it seems NQA doesn’t close the old app domain properly.
  6. If all that works, then your home dry. File, New Query, and off you go. Brilliant tool once it’s going.

Ubiquity

Mozilla has launched an interesting labs add-on for Firefox called Ubiquity. It’s a productivity tool for passionate users, as the Scobleizer writes “It’s not for non-passionate Internet users. They won’t get it.“.

Download it, read the tutorial, have a play, extend it, and increase your productivity :o)

UPDATE 8/Sep/2008: I’ve creaed a ubiquity command for my Pub Finder, to install it, visit my install page. To activate it open up Ubiquity and type pubfinder and hit enter to see the pubs.

From Wikipedia, “Kaizen is a Japanese philosophy that focuses on continuous improvement throughout all aspects of life”. After a review of our systems from a software coach in the department, I decided to instigate a weekly Kaizen session for the whole dev team. (I first heard of the term Kaizen a few years ago when my then department manager spoke of it and I guess now I understanding what he was meaning - thanks Marc!)

The plan is to spend 1 to 1.5 hours a week pairing with another dev investigating a certain area of the code trying to improve it with no strict deliverables. The hope is that the tools and techniques we use in these sessions will become integral to our daily work and code quality will measurably improve.

To feed into these sessions I created a backlog of features to be investigated. These were stuck on cards on the whiteboards for the pairs to select from. Anyone is free to submit a card for an area of code they’d like to look at.

Here’s a few of the cards I created for week 1 to start us off.

Method foo has a Cyclomatic Complexity of 28, aim to reduce it.
Using NDepend i’ve been looking at some metrics across one of our projects. NDepend gives you so much data that it’s easy to be overwhelmed so I chose Cyclomatic Complexity. This found a single method in our code rated at 28 - that’s to say, there are 28 paths through that method. Although we have 13 unit tests for this method we aren’t testing every line of code, and there’s probably some refactoring that can be done.

Class foo has test coverage of 72%, aim to increase it.

Using the TestDriven.net Visual Studio plug-in with NCover we monitor code coverage of our unit tests. 72% is great, but quite a lot of our code has over 95% coverage so this class needs more testing.

There are 8 unit tests currently marked as [Ignore], without simply deleting the unit test, aim to reduce that count.

This is pretty self explanatory. I don’t know why the tests were marked with the Ignore attribute, but they are, and they shouldn’t be.

I was shown today how by using the Duplicates.NET build runner in our Team City CI server it can automatically identify duplicate code across the system. Despite the fact that this project was a greenfield development we’ve still ended up with some duplicate code in need of an Extract Method refactor. Metrics from these reports will feed into our Kaizen backlog.

For those interested, the end result of the above 3 cards was 12, 74% and 4 respectively, so i’m happy we’ve improved the code and got familiar with the tool set.

Had a problem with NHibernate Lifecycle events recently where they appeared not to be firing when I was hitting ISession.Save(entity). After some investigation I finally realised that if you create a new entity, then query NHibernate it may implicitly persist the transient object during a Flush. When it does this any interceptors will be fired at *Query time* thus preventing them from firing when you explicitly call SaveNew. This is by design of NHibernate to ensure the query results are always valid, and is documented here.

Map Tube

I’m not sure how long this has been around, but it’s just popped onto my radar:

MapTube - a place to put maps

It’s a collection of Google Maps overlays most of which display demographics, but this one caught my eye - it’s a map showing the actual location of the London Underground lines, like the Way Out Map.

I love my Mac, but this morning I found the one reason why the glossy UI isn’t always that great - since upgrading to Leopard Apache hasn’t been working on localhost but according to the System Preferences panel all is well.

A quick Google and I found several references to apachectl which is the server control interface. Running “apachectl -k restart” at the prompt returned


(13)Permission denied: make_sock: could not bind to address 10.0.0.1:80
no listening sockets available, shutting down
Unable to open logs

There were 2 clues - the one which I ignored at first about permissions (”i’m logged into an administrative account so it can’t be permissions… doh”), and the reference to the logs. Turns out that on my installation of Leopard the log file folder had failed to be created and thus Apache wasn’t starting.

If you’re having these problems, try the following.

sudo mkdir /private/var/log/apache2
sudo apachectl -k restart

Hey presto everything back under glossy System Preference panel controls once more, and just PHP to get working again.

NHibernate and NOCOUNT

The system i’m working on at the moment recently went into systest and we found a couple of database errors relating which NHibernate was throwing an exception of

Unexpected row count: -1, expected 1

This wasn’t happening on the development system so we took the apparently faulty database from systest and ran it in dev. No errors. This all pointed to an environment issue and after a little checking we discovered that the NOCOUNT setting was different between each database server.

But hang on - when we create the ISession we were creating an IDbCommand and setting NOCOUNT OFF, surely this was enough? Running a SQL profiler I spotted sp_reset_connection commands being executed almost every other statement from NH. This was resetting the NOCOUNT setting and thus it inherited it from the server setting all the time.

Comparing another system’s NH provider versus the one in this system, and I discovered a subtle difference. System A creates an IDbConnection itself and passes it into NH, whereas system B lets NH generate its own connection. It seems that the ConnectionProvider in NH tracks where the connection was created and aggressively releases it if it was internally created.

So my advice is always pass your own connection to NH which allows for better testing and removes the possibility of this happening. Spring.net was a very quick candidate for doing this DI for me.

UPDATE: Since writing my post, i’ve found that providing your own connection prevents NHibernate using the second-level cache so the better solution is to write your own implementation of ConnectionProvider which calls the NOCOUNT OFF on new connections and wire that up in your .config file. Here’s my implementation.

UPDATE 2: I’ve been writing a Linq to SQL app this week, and it turns out that it also requires NOCOUNT OFF, otherwise you get a “Row not found or changed” exception of type ChangeConflictException with a single ObjectChangeConflict object, which has 0 MemberConflicts!

Next »