Category Archives: Programming

All things related to programming

Bad Java, no cake for you! – Java 8 default methods versus Scala traits

Java 8 was released recently and one of the much heralded features is Default methods. Simply put, these allow you to inject functionality to classes via interfaces. This is a new feature in that prior to Java 8, Interfaces could only have method signatures and not have the implementation and only Abstract classes could have method implementations but that has now changed.

Here’s a simple example that prints out “In InterfaceOne”

In Scala, another JVM language, you can do something similar but more awesome with Scala’s traits (its version of interfaces) you can override similar implementations and have a version of multiple inheritance. This example prints out “In TraitTwo”

The secret that avoid that diamond of death is that whichever trait is declared last wins. If I’d swapped around the order that the traits were declared then it would have printed “In TraitOne”

What is even nicer in Scala is that you can declare your class with traits when you instantiate it. You don’t have to declare it at the compile time of the class. This means that you have a powerful way to extend functionality of classes but without the insanity of monkey patching. ThisThe below example also prints out “In TraitTwo” but the class does not extend any trait. This of course is Scala’s cake pattern where you can mix in the traits.

What is slightly disappointing with Java 8 is that you cannot mimic this behaviour. If you try to do this in Java 8, you get a nice compile time error telling us the class inherits unrelated defaults.

I wonder why they chose not to support this. The cake patterns seems like a feature that adds flexibility without being able to shoot yourself in the foot too much.

 

DuckDuckGo

Just as an experiment I thought I would try using DuckDuckGo for searching. In an increasingly big brother world I like that they don’t track you and I like that they only serve requests securely (requests to http://duckduckgo.com get a 301 permanent redirect to https://duckduckgo.com). They also offer a proxy service and the search results seem to be pretty good.

I might give it a month and then report back.

Are Exchanges Just Glorified Chat Applications?

I came across an interesting post here on why Betfair should fear whatsapp. Strange bedfellows for an article but the general thrust of the piece is that a chat application is similar to a financial exchange, in this case Betfair, and could theoretically disrupt its business model. I have to be honest and say it’s something I’ve never thought of.

If you read what’s said then you might think that this is so. The author goes into some detail about the similarities and given the depth of knowledge in some of the other posts on his site you might think that he’s got a point. He even says straight out that “A betting exchange is really just a chat application – in place of messages, you have bets; in place of chat groups, you have markets; and in place of the chat transcript, you have the order book“.

So that’s a fair comparison isn’t it?

Ummm, nope and here’s why. Continue reading

Checking Logback based Logging in Unit Tests

I wrote a simple post a few years ago on unit testing your logging. Checking my logs I’ve seen that it’s always been a popular post as it appears to be something that lots of people want to do.

My previous version was based on log4j and since many people have moved on to logback I thought I would update it. So here it is 🙂

And that’s it.

Seven Red Lines And What You Can Do About It

If you haven’t seen this awesome parody video already, you need to. It’s a great example of what it can sometimes feel like as an expert in a meeting with non-experts.

Buzzword bingo, massive management overhead, ignorance of implementation details, solutioneering, management shutting down needed discussion, condescension, it has pretty much the full package of the worst the world can throw at you.

Of course it’s a taken to the furthest extremes otherwise it wouldn’t be funny but if you’re don’t think there’s a grain of truth to it, ask any technical person if they’ve ever been in this sort of situation and see what they say. It’s not that techies are geniuses and everyone else is an idiot, it’s just that without sufficient understanding almost any area of technical knowledge can be over-simplified to a level that defies reality. This is true for science as much as it is for technology.

The thing is, there another message other than experts have to suffer dealing with idiots all the time; it’s that experts need to be better at teaching and communicating to stop this scenario from happening in the first place.  Continue reading

Six papers for Big Data fans

Big Data, the processing of data sets that do not fit on a single computer, has come of age. It’s not just the level of interest shown at conferences like Strata but also the types of people participating. Sure there are loads of companies out there with products in this space but there are also plenty of end users coming forward and many of these are outside of technology companies. At the London version, one of the speakers was Ben Goldacre, doctor and author of the awesome Bad Science, who discussed the impact of missing data which is a huge issue for medical studies. Even the Whitehouse has weighed in on behalf of Big Data and emphasized its importance to business.

If you are going to use a technology I’m a big fan of going to the source and thankfully in this space, a lot of the published work on this is freely available. So I’ve collected some of the papers that are key to this area: five are about Big Data itself and the bonus one is about operational monitoring for massively distributed systems.

Continue reading

Psychology for Technical Leaders

When I first moved into a position of leading developers I experienced a fair amount of good natured teasing that I’d do my best programming via Outlook and Omnigraffle. While this has been true (thankfully only to a point!) it has been outweighed by the ability to have a far greater say into the resourcing, architecture and implementation of projects and how my company does its work.

One thing that I’ve become painfully aware of is that the operational aspect of this position has a larger ‘people management’ aspect to it than I had previously thought. This is especially true when you extend your view to include recruitment, appraisals, motivating staff and the like and not just setting up your teams to deliver quality code as fast as they can. The soft skills of leadership tend not to come easily to those with a natural technical focus (describing almost every developer ever) so it only makes sense to take advantage of psychology research in the areas of skills assessment and motivation. These is a wealth of knowledge out there and I thought I would discuss a few of the more interesting/useful ones that I have come across.

Continue reading

Why QA needs to change

It’s unarguable that Continuous Delivery has gone from being just a CTO friendly buzzword to a central requirement for a high performance delivery team. It’s no longer cutting edge to merely check in your code to source control and have Jenkins or other continuous integration box run the unit tests. You have to be able to get that code out into a live environment as fast as possible and that means Continuous Delivery. The ability to deliver code into production at will has a direct effect on your bottom line but to do this effectively you need two things, 1) understand the important areas of functionality that the customers really use and 2) be able to test these areas as quickly and easily as possible. The first is a business issue but the second boils down to automating your testing.

The trouble is that most of the industry holds on to a quality assurance process that is directly at odds with this. The reasons are mostly historical but companies have had varying levels of success in the drive to automate QA. The level varies on how highly the company values this ability. So what levels of QA do we commonly see?

Continue reading

Conference Roundup: Velocity EU 2012 and WebPerfDays

The Velocity EU conference is over for this year and what an amazing time. It’s my third Velocity Conference and it just keeps getting better.

There were brilliant talks everywhere. Newer speakers like Andrew Brockhurst (BBC), Dave Nolan and Mark Jennings (Lonely Planet), Mike Krieger (Instagram), Brian Whitman (EchoNest) alongside veterans like Theo Schlossnagle (OmniTI), Artur Bergman (Fastly), Tim Morrow (Betfair), Steve Souders (Google), Mike Rembetsy, Patrick McDonnell and John Allspaw (Etsy.com) and everyone with a compelling message. Even I finally got up on stage and did a talk along with Abe (slides here) where hopefully I didn’t embarrass myself too much. It’s not a joke that hanging out in the hallway really is a fourth track. Along with the Operations and two Performance tracks, with so many smart people the clever kind of rubs off on you as you wander around in search of coffee. You are so much better just for having been there.
Continue reading

Adopting NoSQL – prepare to get it wrong

“There is never any shame in being wrong, only in being too ignorant to learn why you were wrong.”

NoSQL is a hot topic right now; as long as you don’t need ACID guarantees or complex joins you can have a persistence store that is faster, scales better, allows greater schema flexibility and all at a lower comparable cost than a relational database. The number of companies looking to use NoSQL has grown massively and the number of NoSQL solutions looking to feed this grown have blossomed also.

In the eye of this storm are three sets of individuals On one side we have the developers desperate to own the full stack from web app to data store, in the middle are the Ops guys and DBAs used to owning and running the persistence stores and on the other side are the vendors selling their wares. One group focuses on delivering new features as quickly as possible, another ensures that they run smoothly and can be recovered as and when they go bang and the third are deluging these other two groups with an almost impossible amount of information to make sure that their solution is the one being used.
Continue reading