Wednesday, 23 May 2018

Am I an accidental software architect?

I have an opinion about the role of software architects, they should actively contribute code that will go into production for the systems that they provide oversight for.

Recently I have found myself in the peculiar situation of being so involved in technical evaluations, troubleshooting of production issues, code reviews and meetings that I haven't actually contributed any of my own code.

As a "developer" I am not particularly comfortable with this situation.

Saturday, 23 July 2016

Referendum petition data examined

You may have noticed that on 23rd June 2016 the UK held a referendum about whether to remain as a member of the European Union.

When the result didn't go quite the way they wanted, some people participated in an online petition with the goal of having parliament consider re-running the referendum to try to obtain a more significant resulting margin.

Link to petition

The apparent popularity of the petition attracted attention on social and conventional media, so I decided to take a look at the data.

There isn't a lot of information that is exposed, basically a breakdown of numbers by country of residence and a breakdown of numbers by constituency.

By loading the data into an application and sorting it and printing it out I noticed something conspicuous - Vatican City showing up as one of the most popular countries of residence.

Hold on, isn't that one of the least populated countries in the world?

Sure enough, the numbers involved exceeded the public stats of the total population - that literally didn't add up.

Myself and a few others flagged this up on Twitter, so the relevant parties did some checks and figured out how to filter out dodgy data and block later attempts at automated contributions.

My code is available on github.  By looking into the Git history you can see for yourself how the data for country counts changed over time.

Petition Analysis github repo

The code for the petition site itself (not by me) is also on GitHub:

https://github.com/alphagov/e-petitions

Tuesday, 19 January 2016

A post about a post - Java performance for obtaining an array from a Collection

Avid readers may recall that a while back I posted something about creating StringBuilders with the correct initial size to avoid wasted memory allocation and subsequent garbage collection.

Today I came across a blog post that covered a similar topic - creating an array from a Collection - but analysing why advice that had become conventional wisdom may no longer be valid.

It goes a little deeper than my day to day work requires me to understand, but I think it is well worth a read.

http://shipilev.net/blog/2016/arrays-wisdom-ancients/

I'm now contemplating finally getting around to using JMH to evaluate whether my approach to StringBuilders is sensible or programming by superstition.

Monday, 3 August 2015

Continuous improvement

Every few years I like to take a couple of weeks out of the working world to learn about techniques and technologies that are approaching the mainstream.

When I first moved to London back in 2008 I had to learn all about Spring and Hibernate as the local job market was mainly fixated on those technologies.

After the recession cooled down a bit I found my way into a development role based on Hybris - an e-commerce system held together by Spring.

Fast forward to 2012, before joining Springer I dabbled in accessing some youtube APIs to see what would be involved in establishing a degrees of separation relationship between music videos via their related videos.  That was a bit of fun and gave me some insight into some simple performance optimisation options in distributed systems:
  • divide the work up and allocate it to a pool of workers
  • have the workers share a small piece of information to prevent duplication of effort (checking videos that had already been visited).
At around the same time I took an interest in nosql databases.  After attending the inaugural London Data Bar meetup group, I won a ticket to a two day hands on NoSQL databases conference which gave me a chance to dabble with neo4j and MongoDB.

For 2015 I'm taking a dabble in open source products, seeing how they work, contributing some code and improving some documentation along the way.

Do drop-outs have an advantage?

Since starting my quest for a new job I've started to notice that the technical interview process often involves some aspect of computer science that I learnt in my first or second year of university.

Twenty years is a long time to stretch my memory back, so I'm going to have to do an online refresher course and / or some reading to keep myself competitive with the recent graduates - where by recent I mean people who have graduated in the last 10 years or so.

Actually, I remember a guy from my class who was getting good grades but decided to leave university without graduating - I think someone in that situation would excel in these technical interviews.

Tuesday, 21 July 2015

Java 8 Lambda overhead

Intro

This is a follow-up to an earlier post where I was speculating that Java's Just In Time compilation may have been causing significant performance differences when some code was being exercised more than one or two times.

Here is a snippet of the code which I would like to focus on:

int anIndex = Collections.binarySearch(sorted, target, 
(o1, o2) -> o1.compareTo(o2)
);

The title of this post should have given away that the lambda expression made the performance take a hit until something kicked in and probably replace the lambda setup in each loop iteration with a single instance.

Alternatives

Comparator intComparator = Integer::compareTo;
int anIndex = Collections.binarySearch(sorted, target, intComparator);

Also uses some Java 8 magic and performs slowly.

Comparator intComparator = new Comparator() {
    @Override    public int compare(Integer o1, Integer o2) {
        return o1.compareTo(o2);    }
};int anIndex = Collections.binarySearch(sorted, target, intComparator);

Doesn't use any lambda expressions and performs quickly.

The final, slightly embarrassing example:

int anIndex = Collections.binarySearch(sorted, target);

So, I didn't even need to define the method for the comparison.