C# Best Practice: Why a Separate “lock” Object?

Some time about 1995 I noticed that I was writing a lot more concurrent code than the other programmers. It was almost as if someone was deliberately pushing it in my direction… That theme never really changed.

I was rather surprised then when a developer made a comment on something I’d written a few years back, because I was pretty confident I’d covered all the bases.

public class SomeServer
{
    private readonly Dictionary<KeyType, ValueType> queries = new Dictionary<KeyType, ValueType>();

    //stuff

    public void PerformLookup(string someQueryTerm)
    {
        //some logic...
        lock(queries)
        {
            //some more logic
        }
    }
}

The comment was:

Please use a separate lock object. e.g. private readonly object _queriesLock = new Object();

Eh? What?

OK, hands up I missed this. I learnt to use basic concurrency tools way before C# existed. For me C#’s ‘lock’ construct was great because it allowed me a very clear and concise way to use a monitor. As far as I was concerned there was no downside. Why on earth would I want to use a separate lock object?

There are 2 things you need to be really careful about when using a lock in this way.

You must carefully manage the lifetime of the locked object.

Imagine above if ‘queries’ were not a readonly object created at instance initialisation. Imagine if someone did…

lock(queries)
{
    //stuff
    queries = new Dictionary<KeyType, ValueType>();
}

You have to make sure that the locked object is instantiated before the fist lock is taken out and you must make sure that it is not reassigned in any way until after the last lock has been exited.
If you don’t it leads to all different flavours of bad.

If you instantiate a separate lock object at object initialisation, an object that has no purpose other than as a lock, then you know it’s there at the start and the chances of someone messing with it before the end of the last lock are very significantly reduced.

You must be careful not to expose the locked object externally

C# allows an implicit monitor to be created on any object. You can use that monitor by wrapping the object in a ‘lock’ statement.

If you wrote the class to use, say a mutex explicitly rather than the implicit monitor there’s no way you consider making the mutex externally accessible…

public class SomeServer
{
    private readonly Dictionary<KeyType, ValueType> queries = new Dictionary<KeyType, ValueType>();
    public Mutex _queryLock = new Mutex();

    //stuff

    public void PerformLookup(string someQueryTerm)
    {
        //some logic...
        _queryLock.WaitOne();
        try
        {
            //some more logic
        }
        finally
        {
            _queryLock.ReleaseMutex();
        }
    }
}

That’s complete madness – any other class can mess directly with the lock and cause all sorts of unwanted behaviour. Deadlocks are a particular hazard here and compound deadlocks can be really tough to debug.

If you’re using the implicit monitor via the ‘lock’ construct however and you expose the locked object beyond the scope of the class, you are effectively also sharing the monitor.

public class SomeServer
{
    public Dictionary<KeyType, ValueType> queries {get; private set;} = new Dictionary<KeyType, ValueType>();

    //stuff

    public void PerformLookup(string someQueryTerm)
    {
        //some logic...
        lock(queries)
        {
            //some more logic
        }
    }
}

public class SomeOtherClass
{
    private SomeServer myServer=new SomeServer();

    public void SomeMethod()
    {
        lock(myServer.Queries)
        {
            //some logic
        }

        //or worse...
        Monitor.Enter(myServer.Queries)
        //and the Monitor.Exit is in another method that might not get called
    }
}

If you use a separate lock object that you know is private and will always be private then you don’t have to worry about this.

Having written this pattern many, many times in many different languages I’m not likely to fall into either trap. That’s not all that being a good developer is about though.

HwacheonCentreLathe 460x1000

Now, this might seem like a strange tangent but bear with me. I learnt to use an industrial [machine] lathe when I was a kid. They teacher drummed 2 things into us.

  1. Do not wear any loose clothing (e.g. a tie)
  2. Do not leave the chuck key in when starting the lathe

The reason these 2 things in particular were so important was because the lathe I learnt to use had no guard. Either of those 2 mistakes could be fatal.

I’m glad I learnt that, but given the choice would I use the lathe with a guard or the one without? It’s a no-brainer.

We have the same situation here. Unless we’re writing something very specific where memory is absolutely critical, there’s no harm in creating an extra lock object. It provides a useful safeguard against a couple of gotchas that could cause real headaches in production.

Software development purists will be wringing their hands, but they’re not what commercial software development is about. It’s about writing code that does the job in a simple, safe and maintainable way. That’s why using a separate lock object is C# best practice and that’s why I fully support it.

Cultural Erosion

Cultural erosion is often cited as an argument against European Integration. A fortnight ago I was in a Belgian roadside café. They had three different types of mayonnaise in pump dispensers and a man sat eating moules marinière with a tiny bottle of rosé.

Britain has always been a bit special – and that’s not just British exceptionalism speaking. We have always been sailors, explorers; we are a diverse nation that includes cultural elements from all over the globe. It’s one of the things that make us strong.  The question we have to ask however is whether these cultures complement British culture or erode it.

The culture of Britain is under no substantive threat from other Europeans.

Every British town has a McDonalds, Pizza Hut, KFC, Subway and Starbucks. We watch Amazon Prime and Netflix, Nickelodeon, Warner Brothers, Disney, Discovery. We don’t eat moules marinière in roadside cafés, we eat Burger King. We don’t watch François Truffaut films, we watch 20th Century Fox Movies. The biggest threat of cultural erosion that Britiain faces is from the USA.

Remember:

  • Burgers are foreign food
  • Coke is a foreign drink
  • Hollywood is foreign cinema

Other European cultures aren’t immune either, they are more protected because of language but you still find American chains, American food, American films and TV wherever you are in Europe.

We can be much more effective in resisting cultural erosion, from wherever it comes, if Europe works together. The preservation and enhancement of European cultures is a specific objective of the European Union. Far from trying to homogenise European culture there are programmes in place trying to designate, protect and promote individual European cultures (and that includes British culture).

Yes, we are a bit special because we are an island. We mustn’t get carried away with that and think that our past, our present and our future is not inherently tied up with that of the rest of Europe, because it is. Europe is stronger if it acts together, Britain is stronger if it acts with Europe.

First Class Post

Someone recently accused me of replying too slowly on WhatsApp. “First Class post” I replied, “is the most rapid form of communication of which I approve.” I wasn’t joking.

The fact that you’re not going to get a reply for at least 24 hours, if not the best part of a week, tends to rather focus the mind. You have to concentrate on exactly what you want to say, no more, no less and ensure that your communication is complete. There’s no “soz, not what I meant lol” if you botch what you were trying to say.

Writing someone a letter makes you value the communication.

I’ve never been comfortable with the telephone, I consider it a step too far. A letter arrives on your doormat. You might pick it up and open it immediately, or put it aside for later. It’s your choice. You can then think about your reply whilst you’re cooking or re-glazing the east wing.

The telephone however screams “STOP!” when it rings, “whatever you are doing cease it now! Someone wants to talk to you!” It’s just plain rude. On top of that it might not even be a conversation that you wanted to have at that time.

No, the telephone is an abomination and the mobile phone doubly so. There are numerous reasons why one might not answer a house telephone. There is no escape from the mobile, it’s there, in your pocket, constantly buzzing, continually demanding attention.

We now have so many ways of near-instant communication that we have lost all respect for the privilege that technology has brought us. Instead we spend every waking minute in cataclysm of indistinct missives trying to make sense of a world projected into our hands by people who are at best as misinformed as we are.

Don’t get me wrong, I’ve spent the past 20 years delivering ever-improving communication technology into the hands of our emergency services. I’m very much in favour of the technology.

I am more that happy that I have in my pocket a device that lets me communicate in a variety of ways with almost all of my family and friends, with businesses, government and even write articles like this that will be read by complete strangers.

I however respect the fact that I don’t know what the intended recipient of my communication is doing at that moment. I respect the fact that they may not want to reply immediately. I don’t believe it’s asking too much for that respect to be mutual.

One From The Vaults: Testing

Looking for Rhino (real ones, not mocks)

Whilst I was looking for something else I found an explanation I wrote years ago to try to explain to senior management how testing had changed and become critical in the Agile environment. It’s not the easiest thing to try to get across: the business wants features that it can sell. I don’t think I did a bad job, so here it is.

Having now spent a few months with this project I’m very conscious that, at the moment, we don’t have much of a testing strategy. It looks as if we’re trying to offload all responsibility for testing onto the testing department.
This rather implies that our primary testing strategy is manual system testing.
Failed system tests are expensive – and if they impact promised delivery dates they can be a major problem. It would be better if we could have a good idea before we entered a system test whether or not it’s going to pass and that is a software quality management problem.

(Technical) testing should start in the software design. The questions the developers should be asking are;

  1. How am I going to achieve this task?
  2. How am I going to test it?

As an example, user interfaces are notoriously difficult to test, but if one of the MVC style design patterns is used it means that the view (the actual UI) can be separated from the rest of the code. This means you can write a program to test the logic behind the UI without having to try to actually click buttons programmatically.

There are any number of places within the design of software where adding a little thought to how it can be (easily or preferably automatically) tested is of significant advantage.
The more automated testing we can get in the better. If we can get to a position where a substantial portion of the code is automatically built and tested every night that would be great. It means that we, as developers, get continuous feedback about the state of the software.
We can then go into a system testing phase with a much higher level of confidence that it will pass.

This does mean however that we need to start investing in testing, which can be a difficult message to get across. If we don’t however then as the software and the functionality grows and the code-base becomes more difficult to maintain we will be taking ever increasing risks with the future of the product.

It’s a good idea to get this baked in now.

I would suggest that a feature is not finished unless the issue of how it is going to be tested is solved – and that means the automated tests and / or the manual tests written. If there’s no automated testing there needs to be an explanation of why.

The more bodges, work-arounds and spaghetti code there is, the harder it becomes to maintain and the longer it takes to develop each new feature. A product which leads the market can very quickly fall behind because every time someone tries to do something they have to try to unravel all the spaghetti, they then inevitably end up piling on more spaghetti just to make it work and making it worse for the next edit. Technical debt snowballs.

As with all things there’s a balance, I’m conscious we need to get features to market fast, but as the product matures the importance of testing will increase. Automated unit testing ensures that each building block of the project actually does what we think it should do. It’s not a silver bullet for solving all technical debt, but it’s a good starting point. Making code testable enforces certain good behaviours that will increase the longevity of the product.

I do not believe that the current development strategy is sustainable. I am therefore intending to phase in a plan that will, in time, see all new development covered by automated testing and will start to retrofit automated testing into the existing code-base. Inevitably this will slow down the speed we can get features to market, by a known and controllable overhead. Our business model is based on repeat business. If we fail to get a grip of technical debt the competition will overtake us in the mid term and it will invalidate that model.

Stop! Thief!

“That image looks awfully familiar” I found myself thinking when reading an article on vinyl record run-out groove etchings. Then it clicked, it was one of my images, reproduced in someone else’s article without my permission and with no recognition that it was my image.

Image of Vinyl Factory 29 Dec 2017

I’m not a professional photographer, it’s true I do know which end of a camera is the sharp one, but trying to make money out of photos is just more hassle than it would be worth to me. Consequently I’m quite happy for my images to be reused for non-commercial purposes provided that I’m given due credit.

What I do mind however is when my images get re-used on commercial, for profit sites without even so much as an acknowledgement. Even on commercial sites it’s really not worth me pursuing them for revenue (although I reserve the right to do so), what I mind is the fact that it’s downright rude not to credit the original artist.

There’s really no excuse for this – even if someone found the image on a different site a Google reverse image search will very quickly identify its origin. Consequently I have no hesitation in naming and shaming places where I’ve found my images used without my permission and without any recognition.

Original Article Rip Off
A Porky Prime Cut Vinyl Factory
And Twitter
A Porky Prime Cut Two Good Ears
A Porky Prime Cut jack.canalplus.fr
IP Webcam MSN / Auntie Acid
(image and factual content)
IP Webcam Auntie Acid
(image and factual content)
IP Webcam estisuperba.ro

And again (different article)

IP Webcam smalljoys.tv
Goodwood Cobra (racing) conboy.us
Goodwood Cobra (crash) conboy.us
Goodwood Cobra (crash) armeniabirding.info
Goodwood Jaguar D Type (racing) 165.227.181.117
Goodwood Jaguar D Type (rear) 165.227.181.117
Grand Rosela Hotel, adelynndesign.us

Entity Framework Double PK Overwrite Gotcha

I was writing some unit tests: largely out of completeness I wanted to test that you couldn’t insert two records with the same primary key. The code is simple enough.

    var car = db.Cars.OrderBy(g => Guid.NewGuid()).First();
    var pool1 = db.Pools.OrderBy(g => Guid.NewGuid()).First();
    var driverName1 = Guid.NewGuid().ToString().Trim('{', '}');
    var created1 = PoolAllocatedCar.Create(car, pool1, driverName1);
    db.PoolAllocatedCars.Add(created1);

    var pool2 = db.Pools.OrderBy(g => Guid.NewGuid()).First();
    var driverName2 = Guid.NewGuid().ToString().Trim('{', '}');
    var created2 = PoolAllocatedCar.Create(car, pool2, driverName2);
    db.PoolAllocatedCars.Add(created2);

    Assert.Catch<Exception>(()=> db.SaveChanges());

Car Id is the sole primary key of the PoolAllocatedCars table.

Being bit lazy I guessed it was quicker for me to run the code and find out what exception SaveChanges() it threw rather than trawl through the docs and work out what it should be.

The problem: it didn’t throw an exception. So I added some debug to find out what happened, the result is disappointing to say the least.

---===*** FAILED TO NOTICE PK CLASH ***===---

In Memory:
    Car Id [24] Pool Id [49] Driver [bda1d05c-8dae-4648-ab42-736eb8c44b71]
    Car Id [24] Pool Id [08] Driver [9dae73a0-5b8d-45bc-9d0a-f8b73141aa2c]

In Database:
    Car Id [24] Pool Id [08] Driver [9dae73a0-5b8d-45bc-9d0a-f8b73141aa2c]

It would appear that Entity Framework simply overwrote the first record with the second without giving any indication that there was ever a primary key clash.

Now I’m sure that somewhere in the documentation there’s a warning or a note about this but I haven’t found it yet…

Update: It Gets Worse

I was taken aback by the above, that it could be deemed acceptable to treat the explicit addition of a second object with the same primary key as an implicit update with no warning to the user.

I guess then I shouldn’t have been surprised that it even does this after an explicit call to SaveChanges()

The following test gives exactly the same result as the first. This is a massive gotcha.

    var car = db.Cars.OrderBy(g => Guid.NewGuid()).First();
    var pool1 = db.Pools.OrderBy(g => Guid.NewGuid()).First();
    var driverName1 = Guid.NewGuid().ToString().Trim('{', '}');
    var created1 = PoolAllocatedCar.Create(car, pool1, driverName1);
    db.PoolAllocatedCars.Add(created1);

    db.SaveChanges();

    var pool2 = db.Pools.OrderBy(g => Guid.NewGuid()).First();
    var driverName2 = Guid.NewGuid().ToString().Trim('{', '}');
    var created2 = PoolAllocatedCar.Create(car, pool2, driverName2);
    db.PoolAllocatedCars.Add(created2);

    Assert.Catch<Exception>(()=> db.SaveChanges());

The good news is that if you use a different DbContext it throws an exception :- in fact on the Add, not the SaveChanges.

I’m having trouble getting my head around this: I can’t see the logic. If you thought there was a chance that you’d want to update an object after you’d added it to the table then you should keep your own reference to it. If that’s a problem because of scope then your design is probably wrong.

The Jet Set

I really genuinely hate air travel. I will do pretty much anything I can to avoid it. I’ve taken a 16 hour train journey from Suffolk to Barcelona to avoid a 3 hour flight. It’s not that I’m afraid of flying, there’s just something about the whole experience that I find fundamentally unpleasant.

South Africa however is a bit of a trek. Personally I’m completely up for a McGregor/Boorman type epic, but there are certain logistical problems. Mainly not having anything like the spare cash that Ewan McGregor has. Or time. He does seem to have a lot of spare time.

Consequently I’m currently sat on a plane and I’ve been here a while…

There’s never anything on the entertainment system that I want to watch. I have no idea why. It could have my favourite show on there and I still wouldn’t want to watch it. I’ve gone through it all, pawed the duty free catalogue, scanned the in flight magazine and read the safety instructions twice. It’s half past midnight and I am still quite unreasonably awake. It’s at times like this when I conclude that it’s a good idea to listen to Pink Floyd’s Atom Heart Mother.

I’m almost coming to terms with “Alan’s Psychedelic Breakfast” when I suddenly become aware of something plasticky in front of me. I’m just about to “put it over my mouth and breathe normally” when my nose informs me that it’s curry. I conclude that I could in fact eat, not because I’m hungry but because I’m bored and I’m hoping that redirecting some of the blood supply from brain to stomach might help me at least doze.

To this end I order wine too, “Cabernet Sauvingon?”, I enquire. “No, but we’ve got Sauvingon Blanc”, comes the reply. “No thanks,” I interject, “Cabernet Sauvignon is a red” but it’s too late and an open mini bottle of white wine lands on my tray table. I note that is a Marlborough and decide that it’s better the devil you know.

Nevertheless my plan works and half an hour later I’m in the land of nod.

I awake to the rather uncomfortable realisation that I ordered Asian Vegetarian food on this flight. I usually do because it seems more difficult for airlines to murder curry then it does any other type of food. Unfortunately breakfasts can get interesting as I’m about to find out when I’m served bland, generic cheese, coleslaw and sort of bread that tastes like dehydrated semolina pudding.

On the bright side I conclude that breakfast service must mean that I got a good few hours sleep and that there can’t be that much time left on the clock. I don’t dare look however.

I fire up my music player and decide to give the Amaranthe album I curiously downloaded on Spotify a listen. The first track is good, but I very quickly conclude that although Euphoric Dance / Death Metal crossover might sound like an interesting and challenging concept, right here, right now it’s just very, very annoying.

Thankfully the entertainment system has some Chopin and my eyelids are starting to feel heavy again.

There’s an eerie silence when I wake and another strong smell of curry. Chopin has finished and my noise cancelling headphones are busy cancelling out the drone of 4 enormous GP7000 series jet engines.

I lift the lid on the tray in front of me: the airline chefs have surpassed themselves this time and reached a whole new level of achievement. Somehow they have managed to screw up a paneer curry.

Fortunately there are enough other dishes to make a meal. There’s even some spare cheese, just in case cheese in lightly spiced cream sauce wasn’t enough dairy for one meal.

By the time I’ve obtained a cup of tea I’m feeling brave. I’ve had two good sleeps and three bad meals. We must be nearly there, right?

3 hours to go. There’s nothing out the window but cloud. The aircraft cameras are showing nothing but cloud.

Now all we need is some… whoa! Where’s the floor gone? Is that kind of jolt within the tolerances this plane was designed for? “A bit bumpy”, why yes Captain I think we’ve all noticed that. There was a small hint in that if I hadn’t been wearing my seatbelt I’d be sitting in the overhead locker right now.
I then spend the next few moments marvelling at how, firstly, relatively minor atmospheric conditions can hurl a 500 tonne plane about like a piece of confetti and secondly what a superb piece of engineering it is that a 500 tonne plane can be hurled around like a piece of confetti without the wings falling off.
Now however the baby is screaming and the bloke next to me is pale as a ghost and clinging on to the arm rest for grim death.

I try to think of some words that might be of comfort to him, but everything I can think of either makes me sound like a smug git or contains the word “plummet”. I do however make a note to stop jokingly referring to our destination – a well known London airport – as “Splatwick”.

Still more than 2 hours to go but on the positive side, I’m starting to wonder if there’s some mileage in trying to write a blog article about why I hate flying so much…

A Tender Subject

I’d barely got into the corridor before I found myself being bundled into the wall by a rotund sales guy. “What the fuck do you think you’re doing?” he barked in my face, “If you ever pull a stunt like that again I’ll making fucking sure we put you out of business. Consider this a warning.” he stuttered a little and I could see the fear in his eyes: he was not just angry, but terrified. “And I don’t give second warnings. Understand?” he eventually added and with that marched angrily away.

I’d got maybe 15 metres further before another salesperson came up beside me and sniped, “If that’s how you’re going to behave you can forget ever partnering with us.” before he too shuffled off.

What had I done to deserve such attention? Insulted their mothers? Murdered a puppy? No, just give a sales presentation.

One of the way the UK government keeps track of technology is through seminars, they take various forms but this was essentially a day-long event where vendors of a particular type of technology were invited to present their products to a bunch of interested parties within government.

Somehow – despite being a tiny little firm – we’d managed to blag our way onto the list. I’d been to these events before, as the “tech guy” that answers the difficult questions so I knew the format. What I hadn’t done before was actually sit through a whole day of them.

They were dismal. The scripts were poorly thought out, badly structured, omitted important details and contained much that was irrelevant. The presenters were worse. Monotonous at best, incoherent and rambling at worst. By the second or third presentation I was genuinely ashamed that this is supposedly the best of what my industry can offer.

By the second session after lunch half the audience were asleep and I was reasonably convinced that the other half were dead.

When we eventually took to the stage my opening words after introducing myself were “I’m sure you’ll be delighted to hear that this is the only Powerpoint slide I’m going to use.” I then talked for a few minutes about who we are and what the product was whilst my colleague set up a fully working system. We put it up on the projector, handed our various devices to the audience and spent the rest of our time role playing live scenarios that demonstrated the product features.

It was a bold move and quite a risk, there were some very senior civil servants in the room who could have taken umbrage, but they didn’t, they did the exact opposite. At the insistence of one of them our slot was extended to allow for an additional 5 minutes of questions. My colleague and I both ran out of business cards in seconds and took to writing our details on the backs of other peoples. From a sales point of view it could not have gone better for us.

That’s all I’d done. I’d hadn’t bad-mouthed the competition, said anything that was untrue or in any way behaved unprofessionally. We turned up, we told jokes and tried to be as engaging as we could whilst demonstrating a live system that could be set up in less than 5 minutes.

That is the kind of behaviour that the competitors needed to stop. For 30 years they’ve been telling government that software systems are big, complex and expensive. That they take years to develop, months to install and configure and that they require huge, expensive racks of equipment.

Then two guys turn up with a laptop and a bag of kit and prove that none of this is true.

The issue is more complex than one of straight deception, though. These organisations were formed at a time when these things were all true. The organisations themselves have grown to provide a heavyweight framework. They have little momentum and colossal inertia.

They also have huge problems with legacy code-bases. The requirements of government tend to evolve slowly, hence re-writes are rare. Instead old code lumbers on and on and velocity nosedives as technical debt increases [more on that in a minute] and new development techniques, tools, frameworks and languages accelerate the pace that can be achieved within the industry in general.

These factors have reciprocated a framework within government that has grown to expect and indeed facilitate it. The tendering process results in excessively detailed documents that emphasise the minutia and neglect the actual business requirement for the system. These are often produced by committees and are stitched together from requirements drawn from multiple sources – or in other words they’re actually just wish-lists and can at times can be incoherent.

This is a thoroughly unhealthy relationship, it’s not just wasteful, it’s actively counterproductive. It stifles technical innovation and guarantees mediocrity.

More than that though it damages the engineering quality of the products as developers rush to strap on extra features and to modify existing ones in order to meet the letter of the requirement where in reality the product was designed to solve the overall business need and does so perfectly adequately.

This is often a panic scenario too. In order to gain a higher score on the tender a business will commit to what is it at the absolute limit of what it can achieve – often a little more than. The result is the in order to meet the delivery, development have to cut every corner possible. Inevitably this piles on the technical debt.

As the development team crashes from tender to tender its velocity plummets, the business throws more developers at the problem and you end up where we are today. The products are bloated, resource hungry, hideous to configure, often still include archaic technologies that (now) require special environments and are generally impossible to demonstrate anywhere but a dedicated, static suite specifically for the purpose.

That is why 2 people turning up to a sales seminar with a laptop and a bunch of hand-held devices and doing a fully interactive live demonstration caused such a furore. Yes I do believe that everyone else there on that day was at least one of: incompetent, phoning it in or just plain burnt out. None of them however could have done a live demonstration even if they’d wanted to.
To the competitors watching it must have seemed like we’d taken the bar for a sales presentation, which was set barely higher than the crash-mat, and smashed it through the roof. There was no way they could compete.

The reality however is that we weren’t a real threat to them. If we wanted to win tenders then we had to tick boxes. We could undercut them only a handful of times before the same thing happened to us as happened to them 30 years ago. Thankfully we recognised that and stopped responding to additional tenders.

I have to admit that I don’t know what the answer is. As a business or an individual one can make purchasing decisions however we like. If we see something that doesn’t meet what we thought our requirements were, but if we thought about the problem in a different way is actually a far better solution, we can buy that and change the way we work.

Government is different, a democracy must always be accountable to the people. The government must be able to justify why it chose supplier X over supplier Y. A qualitative response is always going to be open to challenges. It is far more robust from a point of view of the accountability of government to take a quantitative approach: supplier X was able to meet more of the requirements than supplier Y. It is also more legally robust, many of the suppliers are large companies that are not afraid of litigation if they believe it might give them a competitive advantage.

One could perhaps say that this adds weight to the argument that the government is trying to do too much and that many of these key areas should be privatised, where a more effective purchasing strategy could be implemented. This however has its own problems: ultimately it’s still public money and all this is doing is to move the point of accountability higher up. The same end could be achieved by just increasing the threshold at which a tendering process is required.
I’m also not particularly keen to live in a country that has a private Police Force and I rather suspect I’m not alone.

The counter-argument is that all such systems should be developed in-house by the government itself. In an ideal world this would be the answer. Unfortunately the world isn’t ideal and the list of reasons why this is a terrible idea is really rather long.

However we spin the model and try to look at it a different way, it’s difficult to get away from the idea of a tendering system that’s essentially scored quantitatively. There have been schemes to try to improve the situation such as to get people from the software industry in ahead of the tenders being written, however their influence has to be carefully managed in case of any allegations of impropriety and they are inevitably associated with the very organisations that will be responding to the tender. Thus this is has not proved and effective means for improving the situation.

I rather dislike finishing an article without at least suggesting something that I think might improve the situation, but I have to admit that I’m struggling with this one.

—=== END ===—


I’ve had a number of comments since writing this article. I can split them largely into 3 categories.

The saddest is the number if people who’ve also reported being directly threatened by larger firms within the industry.

I hadn’t realised how much technical jargon I’d used. Basically “velocity” is the speed at which you can make changes to a product and “technical debt” is what happens when you keep making changes without the proper procedures:
eventually you end up with a big bird’s nest and it gets harder and harder to make changes and it all gets more and more out of control.

A few people within the industry have commented that I’ve made some generalisations and simplifications. This is true, it’s a trade-off between writing a fastidiously accurate article and writing one that makes the point sufficiently well but is engaging enough to appeal to a wider audience.


Tom Fosdick is a Software Architect specialising in Control Room systems for the Emergency Services. His current engagement is with Motorola Solutions, although this article refers to an engagement with another organisation.

Tanya And Tom Do Racing

I have been known to point a camera at a thing – quite often that thing is a racing car. I do it as my own personal challenge but other people seem to like the results, which is one of the reasons behind the TanyaAndTomDoRacing Instagram account.

I do find however that I get asked two questions quite a lot and as Instagram isn’t really the place for a FAQ…

You Must Have Some Really Good Kit?

The direct answer is no, I don’t. In fact this is a pet peeve of mine, not just in photography but in many hobbies.

If you have a good eye, enough knowledge, skill and technique then any entry level major brand Digital SLR camera and many bridge cameras are perfectly capable of taking very good photos – in many cases professional quality photos.

The key about a Digital SLR camera is that it puts control of the optics and the sensor into the hands of the operator, allowing the photographer to make artistic decisions about how the light is captured.

This is one of my favourite (but not technically best) photos, taken at Goodwood Revival in 2015.

It was taken with a Nikon D3000 and a Nikkor AF-S 55-300 F4.5-5.6 D G VR DX lens: entry level kit. What makes the photo is the framing, the choice of subject, the angle to get the reflected sun, the 1/25 shutter speed and a big chunk of luck with the panning.

You can’t compensate for deficiencies in any of those things by throwing more money at it.

Yes, I would have liked a higher resolution sensor and in an ideal world I would probably have used a lower ISO value and larger aperture but I could easily pay 10 times as much for kit to get a photo that is only marginally better.

Digital SLRs are not supposed to be smart, they’re not about image processing and fancy modes to try to make something out of nothing, they’re all about controlling how the light falls on the sensor. There’s only so much that clever electronics and software can help and the best of that is often found not in SLRs – where it might actually degrade the photographic quality – but in compact cameras.

Here’s a case in point:

I like this photo, but it’s not one of my favourites. Taking the standard sharp foreground, blurred background photo is like shooting fish with a Digital SLR.

This photo wasn’t taken with a Digital SLR though, it was taken with a Sony DSC-HX50, a £200 compact camera.

It’s possibly my favourite ever camera, simply because of the amount of power it puts in a genuinely pocket sized piece of equipment.

It does have modes to put optical control in the hands of the user (as seen above), but what you can do is limited – mostly by the physical size of the device. To compensate for the fact that there simply isn’t room for better optics it’s stuffed full of electronics and software.

This shot, for instance, was taken hand-held at a beach cafe somewhere in Indonesia using all the electronic aides available (and needing them).

In an ideal world I would have had a Digital SLR mounted on a tripod and I could have taken a slightly better picture. In an ideal world the person in the picture would be a model who wouldn’t have moved.

The problem is that the person in the picture isn’t a model, she was one of the tour group and I couldn’t really ask her to hang about whilst I set a tripod up or stay still whilst I took the photo. The moment was there, I was able to capture it specifically because I had a compact camera with a night mode that I could select in a second.

The bottom line is this: you can take really good pictures with a sub-£100 camera. The problem is that the capabilities of that camera will be limited, which will limit where, when and the type of picture you can take.

If you spend a bit more, around the £200-£300 bracket you can get cameras that are far more capable and put a good amount of control in the hands of the photographer.

Above that you hit the wall of diminishing returns pretty hard. Between £100 and £200 there’s a huge jump in capability and quality. Between £200 and £300 less so. When you get above that then you can find yourself paying an awful lot of money for very little improvement and you have to ask yourself whether it’s really worth the money.

If you’re thinking of turning professional or if you spend every waking, non-working moment dreaming about photography then fine, maybe it is. For most of us it’s not.

But You Should Sell Your Photos / Turn Professional!

I’m flattered, sincerely and genuinely that some people think my photos are good enough to make money out of, but the reality is that they aren’t.

OK, some of them are and course if people want to pay me to use / print them then we can talk about that… the point is that it’s not worth me actively pursuing trying to sell them.

As I said above, taking the standard “sharp foreground, blurred background” racing car photo is shooting fish in a barrel with a Digital SLR – anyone with any understanding of the principles of photography can do it.

It used to be difficult because with (wet) film you had no idea how good the photo was until you developed it. You can’t do that at the track-side. That means you needed a lot of experience to know exactly what settings and techniques were required because you were shooting blind.

With a Digital SLR you can press the shutter and have the image on a HD tablet within a couple of seconds. You can closely analyse the picture, work out what needs changing and then go again with an improved set up within a few seconds.

At any Formula 1 Grand Prix there must be at least a thousand people doing pretty much that and a good portion of them will be producing shots as good as mine or better. There are only a handful of places you could sell the pictures to and they’re all looking for something that is not just technically good, but has something extra that makes it stand out.

Perhaps something like the first picture in this article, but with a little more sharpness on the helmet and without the smear in the bottom left caused by the head of some bloke who wandered into shot.

I have thousands of photos in and around race tracks and other motorsport events. I have only a handful of photos that I genuinely believe anyone would pay money for.

If you want some idea of the differences then look at the Instagram streams of the professionals:

James Moy @f1photographer
Lollipop Magazine
(Joshua Paul)
@lollipopmagazine (my favourite)
Peter J Fox @peterjfoxy
Sutton Images @suttonimages
Darren Heath @darrenheathphotographer
McLaren @mclaren
Ferrari @scuderiaferrari
Williams @williamsmartiniracing
Red Bull @redbullracing
Toro Rosso @officialtororosso
Force India @forceindiaf1
Renault @renaultsportf1
Sauber @sauberf1team
Haas @haasf1team
Mercedes @mercedesamgf1
Prema @prema_team
Racing Engineering @racingengineering
Russian Time @teamrussiantime
ART @artgp_official
DAMS @damsracing
Campos @camposracing
Trident @trident_team
Rapax @rapaxteam
Arden @ardenmotorsport

 

 

My Favourite Little Friend

Lily Asleep in the garden

[originally written February 9th 2017]

You know before you step out the door. You’re going to the rescue centre, there will be something small and cute there and you will fall in love. You might tell yourself that you’re just going to look, but you’re not. You’re going there because you want to fall in love, you want to share your life.

You also know that one day it will end. The dog that jumps up to greet you after a hard day’s work that somehow makes it all better. The cat that sits and curls up on your lap and just purrs gently when everything seems lost. One day they will die. You know this, but when you’re stood in the rescue centre trying to work out a way of leaving without promising to take all of the animals you don’t accept it. You’re choosing a new life companion and in your head that companionship will last forever.

You know however as time passes that the day it must end is coming closer. When my cat Lily was about 14 I saw her laying motionless on my lawn. I found myself thinking that if she’d passed away I wouldn’t be so upset. 14 is a good age, she’d led a good life and right up until that day she’d been scampering round like a kitten. Yes, this was a good way to die, to find a sunny spot on the lawn on that warm spring day, to curl up and drift off into the big sleep just as she’d drifted off into any other sleep.

I crept closer to see if I could spot any sign of life. As my shadow fell over her I heard the faintest “mip” and she rearranged her paws. She was fine, just far more deeply asleep than usual.

I smiled and carried on walking, but that image stayed in my mind. If that’s how it happened, if one day I just found her curled up having just gone to sleep never to wake up, that would be OK.

Barring a miracle, that is not how it’s going to happen.

Looking back she wasn’t quite right this summer. We used to lose her in the summer, she  rarely came into the house. She’d be out prowling or sleeping either in the garden or in the nearby fields. She’d get sun-bleached, by late August she’d not be a black and white cat, more of a sort of brown stripy cat, not that we really had a cat you understand – she was nature’s child, wild and free.

This summer she spent a lot more time with us. We just put it down to old age and maybe not being as sprightly as she once was. As Autumn became winter however we noticed that she was losing weight fast. We tried a few different foods but none of them seemed to make a difference so we took her to the vet.

Initially all seemed fairly bright, there can be any number of reasons for older cats losing weight and many of them are treatable. As time progressed however there were more test results and we noticed more symptoms and the field of diagnosis narrowed. Sadly it was the benign things that were being eliminated. We’re now in a world where all probability points to her being terminally ill. We’re still not quite sure what the root cause is, but the weight of evidence points in that direction.

I hope that she isn’t in too much pain. Right now she doesn’t seem like she’s in too much pain so I still have that dream, that I walk out into the garden on a warm spring day to find her curled up in the sun, having shuffled off this mortal coil in the gentlest of sun and lightest of breeze.

The reality however is far more brutal. At some point she will be in pain. At some point the pain will be too much. At some point it will be better for my Lily, my dearest companion of the past 16 years if she were no longer here.

And I’m sat here now with tears streaming down my face as she walks all over the keyboard and rubs her cheek against mine.

At some point I will have to kill her.

I am terrified.


I wrote this post a few months ago and I didn’t publish it because at that time I thought it was – well – just too sad. It felt like I was writing her obituary long before she had died.

A few days ago Lily came to see me whilst I was asleep, she curled up and went to sleep next to me. For the first time I can remember when I woke she was still there. I dearly hoped that’s what I’d be able to tell you, that she’d died whilst peacefully asleep next to me. Sadly, as I predicted, that’s not how it was.

She had a brief spell where she seemed to recover a bit, but it soon became clear that it was temporary. She continued to become evermore frail. Over the past 2 weeks however it started to become noticeable that she wasn’t moving or even standing in the same way she used to. Her life seemed to consist of long periods of sitting on her favourite rug staring into space, going to the food bowl, going to the litter tray and coming to us for affection and comfort.

Reluctantly we concluded that by continuing to feed and care for her we were extending her life beyond its natural limit. As it was now clear that she was in pain we decided that to continue to care for her without there being a dramatic medical intervention was unethical.

We visited the vets last Friday and we were not able to come up with any medical solution that would have any reasonable prospect of giving her any further valuable life. We therefore took the decision to end her life in the most peaceful way possible.

We buried her in the garden on Saturday, in one of her favourite spots – almost exactly where the above photo was taken. Currently the spot is marked by a white lily plant. We say hello to her every time we go to work. She’s still with us, still part of our story, still part of who we are.

Rest in peace Lily, 17/04/2001 – 21/04/2017

[original artwork by Emma Green]