Boris Johnson: I am not bothered with civil liberties stuff for terror suspects – Telegraph

Speaking on Sky News, Mr Johnson said: “In many ways the guys who did this kind of thing are very often at the fringes of criminality, lured into terrorism by very cynical and clever idealogues. In many ways they are vulnerable to all sorts of criminality.

“You have got to have a very tough security solution, to be absolutely determined to monitor these people, know where they are, know who they’re talking to.

“I’m not particularly interested in this civil liberties stuff when it comes to these people’s emails and mobile phone conversations. If they are a threat to our society then I want them properly listened to.

via Boris Johnson: I am not bothered with civil liberties stuff for terror suspects – Telegraph.

If someone’s a genuine threat then I want them listened to. Surveillance targeted at those the authorities have reason to believe pose a threat is fine, but we should not be engaging in mass surveillance of the general population, and that’s why I oppose the snooper’s charter.


Posted in All Articles. Tags: , , . Comments Off on Boris Johnson: I am not bothered with civil liberties stuff for terror suspects – Telegraph

On the Guardian’s decision not to print Charlie Hebdo’s cartoons of Mohammed

In an editorial following the Charlie Hebdo murders, the Guardian explained why they chose not to publish Charlie Hebdo’s cartoons of Mohammed:

Some, though, are looking for other shows of support. In social media, the call has been loud – and aimed at several British newspapers, including this one – to take a stand by publishing the very images that made Charlie Hebdo a target. For the most vociferous, republishing a sample of the magazine’s usual fare, which the Guardian has already done, is not enough: they insist that true defenders of free speech would reprint Charlie Hebdo’s depictions of the prophet Muhammad, especially the crudest, most scatological examples.

That case is straightforward. Since these are the images the gunmen wanted to stop, the surviving free press is obliged to deny the killers that victory. No other gesture can show that we refuse to be cowed by their crime. By repeating Charlie Hebdo’s action, we would demonstrate our resistance to the edict the terrorists sought to enforce on pain of death. We show that Charlie Hebdo was not alone.

There is an appealing simplicity to that stance, but it rests on faulty logic. The key point is this: support for a magazine’s inalienable right to make its own editorial judgments does not commit you to echo or amplify those judgments. Put another way, defending the right of someone to say whatever they like does not oblige you to repeat their words.

There are two points I’d like to make in response:

  • The purpose of printing the cartoons that the gunmen wanted stopped is not just to establish solidarity with the victims here but to show those who use violence to try and suppress publications they don’t like that their violence won’t work. However I grant that donating £100k for Charlie Hebdo to continue publishing, as the Guardian have done, is an alternative means of achieving the same goal.
  • If Charlie Hebdo was targeted because they published certain cartoons, as seems likely, and you’re reporting the story then you should publish those cartoons so that the readers can see exactly what it is that the gunmen are claiming they’re committing murder for. Failing to publish them misses out a key part of the story. I felt the British media let people down in 2006 when they failed to publish the Danish cartoons on 2 grounds – failing to stand up properly to the violent intimidation of Jyllends-Posten and failing to let British readers know exactly what all the fuss is about. I think the Guardian has failed on the second point again here.
Posted in All Articles. Tags: , , . Comments Off on On the Guardian’s decision not to print Charlie Hebdo’s cartoons of Mohammed

Je suis Charlie.

My deepest sympathies to the friends, families and colleagues of the Charlie Hebdo journalists who were murdered by religious fanatics.

Freedom of speech includes the right to peacefully express views others may find offensive. Mere causation of offence should not be a crime, let alone used as an excuse for murder, riots, violence or intimidation.

If we let the risk of causing offence silence us, we allow those who would react violently to anything they dislike to dictate what we say, and freedom of speech thus dies.

It seems to me that the murdered journalists at Charlie Hebdo bravely understood this and sadly paid with their lives. Let us hope the perpetrators are caught.

Posted in All Articles. Tags: , , , . Comments Off on Je suis Charlie.

How much of it will become “Scotland’s oil”?

Correction: I’ve been told that although the UN Convention on the Law of the Seas doesn’t explicitly state it, the equidistance principle is used as the starting point for resolution if a dispute reaches the international courts. A case where it was used in the final resolution is the 1992 Canadian – French case involving Saint Pierre and Miquelon a French territory near Newfoundland.

Note that this is a starting point for resolution, not necessarily the end point, so there would still be room for the lawyers to argue over if there is a border dispute on this issue.

My thanks to the poster soupdragon on scot.politics/uk.politics.misc for clearing this up.


I argue here that it is not safe to assume an independent Scotland will obtain the 90%+ share of oil revenues the Scottish government will claim they will get based on getting the geographic share of oil revenues.

A claim that the “Yes” campaign for Scottish independence makes much of is that Scottish tax payers have paid more than the UK average in taxes since 1980/81 (to a tune of a total of £222 billion extra), when you allocate a geographical share of North Sea oil revenues to Scotland. On this basis, the Scottish government further claims that, in terms of per capita GDP, Scotland is the 8th wealthiest country in the world compared to the UK’s 17th place. Similar claims are made in Scotland’s Future: Your guide to an independent Scotland, the Scottish government’s guide to independence, including a claim that 98.8% of UK oil production for the 30 years starting in 2011 would belong to Scotland (e.g. see page 104).

The work of Professor Alex Kemp at the University of Aberdeen is often cited, starting with the 1999 paper he co-authored with Linda Stephen “EXPENDITURES IN AND REVENUES FROM THE UKCS: ESTIMATING THE HYPOTHETICAL SCOTTISH SHARES 1970 – 2003” (UKCS here means UK Continental Shelf). This paper attempts to estimate how much revenue Scotland have received from oil if she were an independent country during this period. A key question is how to determine the boundaries of Scottish waters, and on this point Kemp and Stephen explain:

Read the rest of this entry »

Posted in All Articles. Tags: , , , . Comments Off on How much of it will become “Scotland’s oil”?

On using static methods in Java

This is a bit of a departure for this blog – an article about coding rather than politics/current affairs. This article assumes you’re reasonably familiar with software development, with http requests, with concepts such as object oriented programming (OOP) and unit testing and ideally also with Java.

Consider the following code snippet:


import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;

public class LanguageDetector {

    public static String detect(HttpClient client,
            String languageDetectionUrl, String document) {
        try {
            HttpPost httpPost = new HttpPost(languageDetectionUrl);
            HttpEntity entity = new StringEntity(document);
            HttpResponse response = client.execute(httpPost);
            return Utils.getStringFromStream(response.getEntity().getContent());
        } catch (ClientProtocolException e) {
        } catch (IOException e) {
        return "";

Unsurprisingly the code is used to call a third party service which detects the language of the text you send to it.

It is a simplified version of some code I was reviewing where I suggested altering the method so that it wasn’t static, primarily in order to aid unit testing of the code that was calling it, but also because of a general suspicion of static methods being used outside of certain contexts (see below).

The issue with unit testing is that because static methods can’t be overridden, they can’t be mocked (at least not using conventional mocking frameworks such as Mockito or jMock – see below) and thus you can’t isolate the callers from the static method when testing.  This may complicate the tests for the callers and results in those tests failing because of a problem with the static method rather than the caller, which may take time to figure out especially if the developer isn’t familiar with the code. However if the static method is trivial with no side effects this may not be much of an issue in practice.

My suspicion of this usage of a static method was also heightened by the fact it calls a third party service via http, which is quite a big deal compared to typical utility methods or static factory methods the two main usages of static methods that I have no quarrel with. There’s a lot can go wrong with an http call that’s outside the control of the code whilst invoking a third party service over the network is a notable side effect!

The author of the code queried my suggestion and asked if it was suggested purely for testing and also whether static methods should simply be avoided all the time. Subsequent discussion included mention of Powermock which enables static methods to be mocked thus addressing the testability issue I raised, albeit by doing weird things via byte code manipulation. This may be why the creators of Powermock warn against putting it into the hands of junior developers!

So this led me to ask myself: putting testability aside, just exactly when should we use static methods?

My instinct was basically that static methods were fine for utility classes, such as Math.max(), Collections.sort(), etc and for static factory methods. I might also tolerate them outside of these contexts if they didn’t have major side effects and were doing relatively simple things.

It’s worth noting that when you create a utility method, it will normally operate solely on the arguments supplied to it and carry out a single, well defined operation, e.g.  find the maximum of two numbers or even sort a list. In these circumstances, creating an object in order to call such a method gets in the way of what you’re trying to do, so it’s convenient to have the option of creating the static method. You can also treat these methods as if they were simply extra operators added to the language.

With static factory methods, you’re really just defining constructors. Object creation has to occur somewhere, and using a static factory method can allow you to exert more control over the process. The difficulties of unit testing in this context are no different from the difficulties constructors normally cause for unit testing, so the use of the static factory method isn’t actually making testability any worse here, whilst the extra control of a static factory method vs a constructor is a valid reason to use them, regardless of testability issues.

But why not use static methods all the time? Well if you do that, you’re no longer doing OOP!

Static methods are procedural with the limitations inherent in that approach to programming. Thus choosing static methods vs creating objects is really about choosing procedural programming vs OOP.

One might favour OOP most of the time, but not necessarily all the time. OOP is very powerful as a way of organising your code, but if you’re doing something dead simple then going to the hassle of creating an object in order to invoke a method that does your dead simple thing may be overkill.

So does it make sense to call the language detector service procedurally as happens above? The code is reasonably clear to read and we can isolate it from its callers’ unit tests if we’re willing to invoke the byte coding tricks of Powermock, so one might say why not?

Well, aside from what it’s doing not being “dead simple” (see my comments above), the above code requires its callers to supply both a url and an http client, whether or not they need them for their own purposes. It would make for better organisation of the code for LanguageDetector to hold the url and http client so that the callers don’t need these – the only thing they really need to supply is the document. Since the purpose of language detector is to detect what language the document is written in, that’s a reasonable ask.

Now one could address the above point, whilst sticking to using a static method, by defining the url and http client as static variables on LanguageDetector. One could also make them private static variables that only LanguageDetector methods can access, so as to avoid creating Java’s equivalent of global variables.  But what you’ve then got is effectively just a singleton object with two fields and a method, just with everything implemented statically. If you really need the detector as a singleton, Java has better ways of achieving that. If you don’t need a singleton then why not just create the class normally in the first place?

As for Powermock – it looks like a useful tool you might invoke for dealing with static methods in legacy code (until you get around to refactoring it) or third party libraries that you cannot alter. However the enabling of the mocking of static methods is not an excuse to use static methods when they’re not appropriate.



Posted in All Articles. Tags: , , . Comments Off on On using static methods in Java

UKIP and the next general election

In my previous article I commented that I didn’t expect UKIP to gain more than a handful of seats at the next general election. Here I shall expand on the impact I’d expect UKIP to have, assuming a “no” result in the Scottish independence referendum. I make this assumption simply to narrow the scope of this article – the fallout from a “yes” result is rather unpredictable and would be best discussed in article of its own.

I expect UKIP’s share of the vote to fall back to at least 3rd, if not 4th place, for various reasons. Euro and local elections do not determine who is in government and thus people’s motivations for voting the way they do or for staying home won’t be the same as for a general election. For example, the results we saw are likely to be in part the consequence of a protest vote that won’t replicate in the general election, and the higher turnout of a general election will probably see the major parties voters coming out more strongly, which may be enough for the Lib Dems to retain 3rd place for example.

That said a recent poll indicates that 86% of those who voted UKIP in the Euro elections intend to do so at the general election. At the Euro elections UKIP got 4.3 million votes. If the poll is correct and UKIP retain 86% this would amount to ~3.7 million votes. In the 2010 general election UKIP got 919 thousand votes, so this would represent a 4 fold increase, and 12.45% of the vote (assuming the same number of voters as in 2010).  In such a scenario, UKIP would probably get a few seats at Westminster, and if the Lib Dems implode badly, they might even supplant them as the third party, but this would be based in the Lib Dems losing most of the 57 seats they currently have.  More likely is UKIP gets a handful of seats, the Lib Dems lose a few but retain their 3rd party status. The Lib Dems are the masters of carefully targetting their campaigns and will also benefit from incumbency so I don’t expect the number seats to decline dramatically even if their share of the vote drops a lot.

I thus think the impact UKIP will have more to do how they impact on the other parties votes, particularly in the marginal seats, than with the number of seats they might win. A recent article in the Telegraph points out that there are places where UKIP won lots of councillors in the local elections and which are also marginal Westminster seats for each of the 3 main parties. In these seats, even a small UKIP surge could upset the balance and result in a change of party even if UKIP themselves don’t get elected. It is for this reason that I’d expect some pandering towards the people who’ve voted UKIP will be done by the major parties in an attempt to prevent such cases arising. Indeed I think we’re already seeing signs of this happening.

Of course if UKIP win some Westminster seats it is possible they might form part of a new coalition government. I’d expect them to win less than 10 seats, so it would require a party to be just short of a Commons majority for UKIP to take them across the threshold. This seems somewhat unlikely to me – it would be a knife edge coalition and the Lib Dems would probably offer a coalition with a bigger majority and lower likelihood of flaky demands.


Posted in All Articles. Tags: , , . Comments Off on UKIP and the next general election

Initial thoughts on UKIP’s advance in the Euro elections

So UKIP topped the poll in the UK’s 2014 euro elections, returning 24 MEPs compared to Labour’s 20 and the Tories 19, with Lib Dems holding onto just 1 seat (they used to have 11).

Even with the surge of anti-EU parties elsewhere, it is unlikely this will have a big effect in the European Parliament because the pro EU parties still easily outnumber the anti-EU/EU sceptic parties there. However in terms’ of the UK’s domestic politics, and the debates about EU and immigration (the two main themes of UKIP’s campaigning) there could be a significant impact in various ways:

  • The Lib Dems, the most consistently pro EU of the major parties in Britain, who took Nigel Farage and UKIP on directly in the campaign and positioned themselves as “the party of in”, have had a disastrous result. They were lucky to hold on to their single MEP and fell to fifth place behind the Greens.  Those who believe in the EU should be concerned that the one party that was unashamedly, full throttle, pro EU got a drubbing after taking on UKIP in a high profile manner.
  • UKIP are unlikely to win more than a handful of Westminster seats at the next general election, due to the vagaries of first the post, the higher turnout, the fact we’ll be electing a government, and the likelihood they’ll fall back to at best 3rd place in share of vote. However, I’d expect the other parties to pander more strongly to the concerns of the voters who voted for them. Expect more talk of immigration controls, reform of the EU or pledges of referendums on EU membership.
  • A bigger impact may come from the reaction in Scotland to these Euro election results – Scottish politics has swung to the left of British politics generally for  as long as I can remember.  With UKIP’s perception as a party to the right of the Tories, the prospect of UKIP influencing Westminster politics may give a boost to the “Yes” campaign in the Scottish independence referendum. If that boost is big enough for “yes” to win the referendum, then British politics will have the biggest shakeup it’s seen for centuries as Scotland negotiates independence. The fall out would make the next Westminster general election unpredictable.