Monday, 13 December 2010

Edward Deming and his Red Bead Experiment, in practice.

We had an interesting brown bag lunch meeting the other day about Edward Demings red bead experiment. I've heard and read about it before but never got to participate, it was interesting, thought provoking and fun. Some good discussions afterwards as well.

Edward Deming was a management consultant and statistician. He had a massive impact on the management styles and philosophy of Japanese business in the 50's and 60's. He used the red bead experiment to illustrate the impact that a system, and traditional management approaches, can have on individuals who work within a system, and how traditional management approaches (slogans, the usefulness of targets, annual appraisals and financial rewards) are not always (if ever) that effective at improving quality.

Details on the red bead experiment and how it is performed can be found here For our results in the actual experiment read on.

The session was run by a thoughtworks colleague, in a really good way, we had the workers, the management, the QA staff, and lots of fun.

The workers were set targets of 5 defects max per person ( a total of 15 per iteration for the team)
The 3 workers, were split into 2 average and 1 good (what ever that means)

Iteration1234Developer Totals
Iteration Totals2323202591

After iteration 1 workers were told that their efforts were not good enough, and basically told off by management. This made no difference, and so, after iteration 2 the workers were given incentives and appraisals, if they upped their game they would be given hard cash. This worked and management were encouraged to do more of that, offering bigger rewards for better performance.
But iteration 4 was the worst yet and so managers assumed that the incentives had failed because no one actually achieved them last time.

So what does this actually tell us?
That in a fixed system where the workers have no ability to manage or better themselves or their work, the management effectively can not effect workers performance though traditional carrot and stick management.

How does this relate to Software?
I have found that as software developers we don't get to change the system as a whole very often. Often software is seen as the solution to business problems, when actually changing the system would be a better approach. Just by making the process electronic doesn't always work and often makes things worse or masks the underlying problem. This is just another reason why software projects fail.

The experiment also relates to the software development process. If software engineers work in a rigid system where QA and strict process is seen as putting the quality in. Where the engineers don't have the ability to change their environment (technology, process, physical environment, methodology) then no amount of incentives, slogans, rewards can make the software produced better (less defects, meeting business requirements more effectively, etc.). I have seen this at several clients, and can say that clients who have empowered workers have a big advantage, these companies have better motivated, more professional developers and in the end better software.

Systems Thinking is a really interesting field at the moment and if you want to read more do a google for Edward Deming, systems thinking and John Sedden.

So even if you are CMM level 5 (i.e your processes are robust and repeatable) you can still have quality issues, The red bead experiment highlights that it is not process that produces quality, nor rewards, targets or incentives, its the system within which workers work that matters and their ability and motivation to help change and adapt the system.

Tuesday, 7 December 2010

Selenium 2, webdriver for .net c#

Webdriver tests that are fast to write and fast to run are essential for BDD. I was really supprised at how fast your tests can actually run, even the setup is quick IE opens instantly, providing a very quick test code loop.

1. Download selenium 2 from i got for this exmple
2. Add project references to nunit.framework, webdriver.common and webdriver.IE or webdriver.firefox
3. Using NUnit (No tutorial for that here, google it) create a test class that uses webdriver

using System;
using NUnit.Framework;
using OpenQA.Selenium.IE;

namespace AcceptanceTests
    public class Class1
        private InternetExplorerDriver _driver;

        public void FixtureSetUp()
            _driver = new InternetExplorerDriver();
            _driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 30));

        public void FixtureTearDown()
            if (_driver != null) _driver.Close();

        public void GoogleShouldBeInTheTitleWhenNavigatingToGoogleHomePage()


            Assert.AreEqual("Google", _driver.Title);

4. Run your tests
5. Done

Wednesday, 3 November 2010

Android, how easy is it to deploy or install your own app to your phone

The answer is very easy

So you have spent a few hours developing a new android app (ive been using the eclipse IDE) and you have been testing using the adb emulator, but you want to see something on your very own android hardware (ive got a HTC Desire).

These are the steps ive followed:
  1. Build your .apk package.
  2. Connect your phone to your pc in disk drive mode (this enables you to mount it on your pc).
  3. Browse to your removable disk (this shows up as drive G: on my machine).
  4. Copy the .apk file that was generated by the build to your phone and remember where you copied it to.
  5. Disconnect the phone.
  6. On the phone use a file manager app like 'ES File Explorer' or 'ASTRO File Manager' and browse to the .apk file you copied on in step 4.
  7. Open the .apk file and select install.
It really is that easy, none of that iphone certificate nonsense, or limited use to tolerate, lets just do it :-)

Setting the date on Android emulator adb

To set the date on your android emulator use the following command from the terminal

adb shell date -s 20101023.130155

This sets the date to be Oct 23rd 13:01:55 2010

Friday, 29 October 2010

20 things that are wrong with TFS, and counting

We have recently spent a lot of time using TFS 2008, im no expert with this tool but it seems to me that there are lots of issues with it. Its not that im trying to do some TFS bashing but my last project using subversion didn't have source control problems.

As always though if anyone out there can put me right on any of these issues please do so.

  1. Renames and deletes don't always properly get merged between trunk and branch and back.
  2. We had really random deletion of files when doing a merge from a branch that has had a baseless merge applied to it, (files were randomly deleted off the trunk during merge) these files existed in our branch and the trunk before the merge, but were removed off the trunk after.
  3. After doing a baseless merge (using power tools on the cmd prompt) you then can't reliably use the TFS GUI to do things like merges, you must use the command line tools.
  4. Tooling just doesn't work when merging, files that have no conflicts just don't auto merge all the time and requires manual intervention for no reason. This is intolerable when refactoring and you have changed 100+ files.
  5. No ability to create patch files which can be subsequently applied to other branches.
  6. Changes to one branch cant be merged into another branch unless you go via the trunk.
  7. You cant merge workitems between branch and trunk, even though workitems are the main unit of work in TFS.
  8. Many standard features like rollback are not built in. It requires an additional 'power tools' download (There is no GUI for rollback)
  9. Can't seem to rollback to a given point in time, you can only rollback 1 changeset at a time, this just seems wrong to us?
  10. Using TFS built in diff tool reports lines that have no changes to have changes. And does not line up source and target very well making the tool very hard to use when trying to spot important differences.
  11. Doesn't know that files or folders have been added unless you tell TFS in the GUI, This can easily lead to files not getting checked in if they were not created in visual studio.
  12. The GUI doesn't always update to reflect the state of the source control, requires a refresh, this mainly effects the pending changes view.
  13. The UI is confusing in that if you are browsing the source and click on a file to open it, it opens the local copy not the one in source control. Also it doesn't tell you that the local is different from the one in source control.
  14. When you add a new mapping to your workspace the tool says 'do you want to update your workspace?' when you say yes it then goes and gets everything from your workspace and updates everything, you expect it to only get the changes due to the new mapping. this caused us quite a lot of confusion and wasted time, but luckily nothing was lost.
  15. Sometimes labels disappear, completely, as if they were never created.
  16. A label to label comparison does not always give the same results as a date to date comparison, even though the dates used are the same as when the labels were created.
  17. Checking out (not getting) the entire branch takes ages (40 minutes plus) even though the source is not really that big (70,500 files), we actually gave up in the end and 1/2 were checked out 1/2 were not.
  18. Deleting a branch took 40 minutes. Did a delete in TFS of the branch folder (took 10 mins) got a pending delete dialogue box, tried to check in the delete which failed with the error 'the local copy is not up to date', so we then undid the delete which took 20 mins, got the latest source (3 mins) and finally did the delete again (10 mins). Why cant TFS tell us up front the delete wont work because our file system is not up to date? and why when doing it in the TFS GUI does our local file system matter? especially since we had no pending changes?
  19. When you re-branch you lose your branch history.
  20. If you tolerate this, then your code will be next...

Tuesday, 28 September 2010

C# .net method call performance

I’ve recently been in a conversation with another dev about a code base and had an alarming exchange regarding method calls and performance.

Alarming because he claimed that the reason that the methods in the system were so long was because someone higher in the dev chain 'tech lead' or 'architect' had claimed that it was expensive to make method calls???

I’ve seen my fair share of long methods, awful things that destroy reuse, developer productivity, and introduce many, many tangled bugs. These usually evolve because the devs are under pressure to get things out of the door on tight schedules, or by inexperienced devs who unfortunately don’t know much better. Personally I like to try and keep my methods short <20 lines, to keep to the principal that a method should only do one thing, do it clearly and well (so its easy to read, understand and change), you know all the usual stuff. But I’ve never seen the justification for long methods to be because of performance...

so i thought what is this performance gain of long methods? After googling around I didn’t find anything (if you do let me know) so i wrote a program.

Essentially it consisted of 2 loops, one to do a simple calculation in line and one to call a method to do the same calculation.

for (int i = 0; i < LoopCount; i++ )

for (int i = 0; i < LoopCount; i++ )

i took timings before and after each loop and recorded the results

LoopCount= 100000000
elapsed time = 234.447 milliseconds
elapsed time = 640.8218 milliseconds
Method call loop took 406.3748 millisecs longer than inline loop for 100000000 calls
Thats a cost of 0.0000041 millisecs per method call

i wasn’t sure about the results so i decided to run it again, this time with ten billion iterations of the loop, these performance penalties must show up with that many calls.

LoopCount= 1000000000
elapsed time = 2250.6912 milliseconds
elapsed time = 6376.9584 milliseconds
Method call loop took 4126.2672 millisecs longer than inline loop for 1000000000 calls
Thats a cost of 0.0000041 millisecs per method call

its quite conclusive, method calls don’t really add up to all that much overhead, as we all expected.

Sunday, 12 September 2010

Azure Learnings

A few months ago I played with Azure, experimented with all the storage options (table, queue, blobs) web and worker roles, made things interact and generally got to know what was possible, not possible and how to do things. It was interesting, i gave a few presentations to the company I was contracted to at the time but in the end it was all just exploration, they were never going to take it up (they own lots of their own hardware, i mean Lots, and besides in my view there are issues with going to Azure as a solution for that enterprise problem), also I didn't see any use for it in my own personal projects.

I had a MSDN account which at the time entitled me to 750 compute hours a month (a compute hour is just a measure of how long your roles have been deployed in the cloud), and was careful with my deployments, always take test deployments down to minimise the total compute hours.

Anyway two problems:

1st. I didnt check my subscription(why would i?) it turned out i had the basic "starter" subscription (50 free compute hours) not the MSDN package (750 free hours).

2nd. I did a demo and someone wanted to use it afterwards so i left it up (one web role and one worker role) and then forgot about it... opps. To add to my woes my hotmail account is not my primary email account so the billing was not coming to me, i only just found it when I happened to be on hotmail.

To cut a long story short I got charged £50 + £120 + £120 for the honour of having my dummy website sat doing nothing on the azure application fabric... I;ve since talked to Microsoft and cancelled my azure account, i see no need for it, I'm not going to use it any time soon, and wanted to make double sure all my web instances were gone. but after talking to them i have got last months money back, better than nothing but still... i guess it was my fault for not checking my package, my running instances and my email, stupid boy.

Morale of the story to all you perspective Azure developers out there, check your subscriptions, and always take down your test deployments, always.

Wednesday, 1 September 2010

Site creation with google sites

Just been through the process of setting up a new website new picasa site and new flickr account for my brother who is setting up a photography business.

It was actually quite easy to do once you get used to navigating your way around the site and the wysiwyg editors. Managed to fully set up google analytics and web master tools also.

Now I just need to make sure my brother updates his content.

Thursday, 26 August 2010

Vodafone, HTC Desire fiasco update

Talked to Vodafone customer support again, (its my twice weekly activity now, well has been for 3 months) and have been told I'm not a priority, basically there is a supply problem (i know) and there is a waiting list (makes sense) but as I'm an existing customer (not a new one, or getting an upgrade) then i cant be put on the list, therefore the only way to get the phone is for me to ring up every other day and enquire if they have any stock to send me yet...

They did get 3 HTC Desires in today, but all went to new customers on the list. What this tells me is this: If you receive your new phone from vodafone but there is a problem with it cancel your contract ASAP (before the 14 day cooling off period) and once you have sorted that out do the new customer thing again. it seams that if i had done this i would have the new phone by now. just a warning to you folks, don't accept the promise that a new one will be coming your way any time soon.

On a slightly different note the Vodafone lady in the call centre was very nice, apologetic and honest, its definitely a system problem, not a people problem, why cant i be put on the list? clearly its a money problem, existing customers don't make the company any more money.

Tuesday, 17 August 2010

Vodafone, HTC Desire fiasco

So I've had a contract with Vodafone for over 3 months now. I think it was early may that I actually signed up for a contract with them and got my shiny new HTC Desire, I was pleased. Very pleased :-)

But after a day or 2 I found it was broken :-( if you used it for any length of time it would just quit, turn off, then not turn on for a while whilst it cooled down, oh and there was the strange squeeze thing I mentioned in another blog post.

I complained only 2 or 3 days after I received the original, I thought it would be straight forward, new for new, but unfortunately no stock, the desire is very desirable and there were supply problems.

So I waited and waited, I rang back twice a week to check on progress, I was not using my desire at this point as it was unusable, switching itself off randomly. Back to my trusty old nokia (7 years and still going strong)

And I waited.
Finally, finally after ringing twice a week for 2 months i got a replacement phone :-) yay at last, but I was told to keep my batery, sim and memory card from my other phone, strange, oh well, got my new phone now. :-)

But no, still broken, still with exactly the same problems as before.... ARRRRG, it was the battery all this time, i told them i thought it was, dam it.

And wait what's this, there is as small scuff mark on the base of the phone, its brand new isn't it?

So rang Vodafone back and said it still doesn't work, and also is this phone I have new? there is a scuff mark on it? after much a to-do I got the answer that its a reconditioned phone, and we will send you a battery (which they did but I suspect its not a new one as it came in a jiffy bag).

Anyway after some challenging discussions I got agreement that it was an error to send me a reconditioned phone, apparently an error in the system (problems with phones over 1 month into the contract get refurbished replacements), since I was 2 months into my contract I get a reconditioned one... even though id reported the problem on day 3... But the supervisor on the other end was reasonable in the end and agreed I should have had a new phone sent not a reconditioned one, and so I'm waiting, again.

And waiting and waiting, I ring back twice a week again, try to get a date but again they are out of stock, out of stock, out of stock.
Do Vodafone ever sell the HTC Desire? I know its a popular phone, that there are supply problems but in effect its been over 3 months now, you cant tell me you have not had any stock in 3 months? really?

I suspect its far more profitable to sell that new handset to a new customer than to sort out your existing ones?

I'm a bit disappointed really, as you can imagine, cause I've been using Vodafone for all my mobile life, years and years, even whilst abroad, and always had excellent service. I've had friends with orange who had trouble and problems with the provider and I've always said come to Vodafone, they are great, but seams like things change, or just maybe I've just got really unlucky.

Thursday, 13 May 2010

HTC Desire shut down problems

So ive got a brand new HTC Desire, and instantly loved it, but its not right...

If you talk on the phone for 5-10 minutes the phone will just switch off? if you use the internet or any other functionality the phone will soon enough just switch off. sometimes if you just gently squeeze it will just shut down.

Once it has shut down the status light flashes green and orange, sometimes it wont even shitch back on for ages...

So ive got in touch with vodafone, and they have been really good about sorting it out. they have quickly agreed to replace it :-) but there are none in stock at the moment, and none due in till the 23rd i think... boo

video of the squeeze

As you can see it works pretty well, quick navigation, just dont squeeze it.

Wednesday, 27 January 2010 and asp.mvc, Getting started with dependency injection

This small tutorial gives you the quickest route (that i know) to getting microsofts mvc working with for simple DI (Dependency injection) or IOC (Inversion of control) to aid in testing and maintanance. Yes i know can do much more but this is just a very basic how to.

Download Prerequesits
First get asp.mvc, download and install from here (im assuming you have vs2008 or like wise for this tutorial)
At the time of writing im using vs2008, xp and mvc 1
downloaded here
but im sure mvc 2.0 would be much the same to set up DI

right click on your existing solution (or alternativly create a new one)
then add, new project, web, pick ' mvc web appication' from the list of templates contained
this will make a brand new mvc web app, all configured and ready to go, build and run it you should see the default mvc site out of the box.
now to get spring running and injecting goodness into it.

first download
im going for the latest production release 1.3.0

then download MVCContrib from
im using the latest stable release for mvc 1.0 here
get both the main download and the extras package (the spring IOC assembalies are contained in the extras package)

reference the following assemblies from the solution: spring.core, mvcContrib and MCVContrib.spring

Substitute the default controller factory for the spring factory provided by mvcContrib
Add the following to the head of global.ascx
using Spring.Context.Support;
using MvcContrib.Spring;

add IOC to your global.ascx so that application_start creates a spring context

protected void Application_Start()

private static void ConfigureIoC()
ContextRegistry.RegisterContext(new XmlApplicationContext(false, "assembly://MvcApplication1/MvcApplication1/objects.xml"));

var ctx = ContextRegistry.GetContext();


add an objects.xml file that will hold all the spring configuration

<?xml version="1.0" encoding="utf-8"?>
<objects xmlns=""

This objects.xml must be an embedded resource into the assembly, right click the file, properties, and change it to an embedded resource. If you miss this step you will get an error stating 'Could not load file or assembly Spring.Core.....' basically stating that the assembly didn't contain the objects.xml, which is the dependency spring is looking for.

at this point if you ran the code you would get the error
No object named 'HomeController' is defined : Cannot find definition for object [HomeController]
This is good, it means that spring is looking for a definition of your home controller but cant find one.
so letes tell it about it

add this to your objects xml
<object id="HomeController" type="MvcApplication1.Controllers.HomeController, MvcApplication1">

now when you run the app you should get the same boring default mvc home page again, brilliant, looks like its working, now to test the dependency injection, this is what we have been waiting for.

Inject a custom object into the homeController
So the easiest way to demo this is to echo some text out onto the screen that comes from a dummy data
add 2 objects to the model folder

using System;
namespace MvcApplication1.Models
public interface IHelloDAO
String Hi();

namespace MvcApplication1.Models
public class HelloDAO : IHelloDAO
public string Hi()
return "This is data straight from HelloDAO";

now we are going to use this DAO (Data Access Object) in the controller to get some data from the model by using the Hi method on the IHello interface.
the class should now look like this
public class HomeController : Controller
public IHelloDAO HelloDAO { get; private set; }

public HomeController(IHelloDAO helloDAO)
HelloDAO = helloDAO;

public ActionResult Index()
//ViewData["Message"] = "Welcome to ASP.NET MVC!";
ViewData["Message"] = HelloDAO.Hi();

return View();

public ActionResult About()
return View();

We added a new constructor which takes an instance of IHelllo (this is the think that is being injected in), and we have used the instance to get the message by using HelloDAO.Hi()
finally import the relevent model namespace at the top of the file.

again if you were to run the app at this point you would get the following error:
Cannot instantiate a class that does not have a no-argument constructor [MvcApplication1.Controllers.HomeController].
which indicates quite clearly that the controller is not configured correctly. Basically spring is expecting a no argument constructor, but the real class dosent have one.

Configure Spring
Now all that remains is to wire the dependencies in the objects.xml which should now look like this

<?xml version="1.0" encoding="utf-8"?>
<objects xmlns=""

<object id="HomeController" type="MvcApplication1.Controllers.HomeController, MvcApplication1">
<constructor-arg ref="HelloDAO" />

<object id="HelloDAO" type="MvcApplication1.Models.HelloDAO, MvcApplication1">

you can see we have added a parameterised constructor to the controller through wich we are injecting in an implementation of the HelloDAO interface.
The index remains the same as it was out of the box and should display our message instead of the default 'Welcome to ASP.NET MVC!'

lets run it.
magic, you have configured your first and hopefully not last controller through and asp.mvc

now your ready for part 2 ( and asp.mvc, even more dependency injection)