Foreign diplomacy is a mucky business, but every so often you are presented with simple choices.
Imagine the following situation. An election is taking place in a neighbouring state which you rely on for your nuclear and defence plans. The incumbent has previously described you as an "obstinate kid" and refused to shake your hand in public. The challenger is riding high in the polls and looks set to win.
Do you a) throw your chips in with the new guy? b) stay removed from the election and then welcome the winner, a practise which happens to correspond to diplomatic convention, or c) back the incumbent and rudely snub the challenger.
b) is the right answer, but if you’re incapable of that, at least a) makes a rash kind of sense. c) is a quite insane way to proceed and that is precisely what David Cameron did.
The prime minister threw his lot in with Nicolas Sarkozy in two ways. First, he snubbed Francois Hollande on his trip to London, leaving him to meet up with Ed Miliband, who respectfully took a senior team for talks. Then he stood next to Sarkozy, who was already dead meat according to the polls, and threw his lot in with him - even offering to go campaigning with him.
Diplomats who have worked with Cameron have often noted he 'shoots from the hip'. That is a charitable description. The prime minister's judgement on foreign policy is deeply suspect. At best it is unseemly. At worse it is humiliating.
The same self-defeating tendency was being exhibited when Cameron became star-struck by Barack Obama on his recent trip to Washington. The US president has "moral strength, with clear reason and with fundamental decency" Cameron blushed, going totally overboard.
The result? The comments shocked Mitt Romney's camp, which happens to be running for the presidency this year as candidate for the Conservatives' sister party. One of his advisers told the Guardian it made Cameron look "not very skilful". The Republican's trip to London for the Olympic Games might now see him avoid the British prime minister. Frankly, that's unlikely – election candidates need to be seen with world leaders to boost their foreign policy credentials, which was precisely why Hollande wanted to meet with Cameron.
Obama remains likely to win the election, but it's not a done deal yet. Why take the risk - especially when the gain is so negligible? Just days after Cameron's lavish praise, Obama said he was "neutral" on the Falklands Islands.
It's just one error after another for Cameron. He travelled to Egypt immediately after the revolution, but his decision to take arms dealers with him made the UK look cynical and brutal rather than forward-looking and daring. It was as if Cameron was trying to write Noam Chomsky's books for him. Now when he undertakes sensible, meaningful visits to places like Burma to welcome the local elections, he does so under a shadow of suspicion.
In Europe, the British prime minister is friendless and isolated after he sacrificed a place at the dominant centre-right grouping to form an alliance of fringe elements – all in a knee-jerk bid to satisfy his own eurosceptics. When the time came for an EU-wide fiscal treaty, Cameron was in no position to influence it. He had no leverage to convince opinion formers of his position, in the same way that he now has precious little leverage with Romney or Hollande. His veto changed nothing, except for the precise name of the treaty. The new grouping will use EU institutions and enforcement agencies. It is Britain which has been frozen out.
Cameron's fortune is that, among the debris of countless foolish foreign policy judgements, the most substantial decision he took enjoyed better headlines. On Libya he managed to secure a UN resolution few thought possible and enter a conflict which eventually resulted in the overthrow of Colonel Gaddafi.
Those who shoot from the hip sometimes hit their target, but that doesn't make it a sensible way to aim. And even here, in the midst of his greatest foreign policy triumph, there are traces of failure. The reason Russia and China are now so stubborn on Syria is they feel they were misled on the Libya resolution, which was not seen as an invitation for regime change.
The key to understanding Cameron's foreign policy judgement came in 2008, when he flew, as opposition leader, to Tblisi and stood alongside Georgian prime minister Lado Gurgenidze to demand an end to Russian hostile action. One could be charitable about this decision. It was not altogether different to the message from Washington and Europe. But the question is not whether that was the right thing to do. The question is what a leader of the opposition was doing there, when the then-prime minister of Great Britain was playing a quieter game.
The Tblisi decision was opportunistic, rash and badly-thought out. Four years later it appears to be the precursor to Cameron's entire foreign policy.
The opinions in politics.co.uk's Comment and Analysis section are those of the author and are no reflection of the views of the website or its owners.