Premature Abstraction

In an ideal world every abstraction is pure. We don’t live in an ideal world (yet) though. Abstractions can be hard. They can cause frustration and people to give up on them or wait for the perfect solution.

In my experience, often the right thing to do is wait for the perfect abstraction but I think in a lot of cases it is right to go ahead and do the abstraction. You can always replace it or refactor it if need be but I think the key is not over doing it if not sure – keep it simple.

You want a good return on your investment and you dont want to make a brittle abstraction which limits peoples options down the line or causes tears and frustration.

Also, as with everything you should talk to people and get advice before creating your monster.

Single Reponsibility and Seperation Of Concerns in the real world

A straight forward example I encountered recently in a common lib I use at work.

The library is reasonably new and a work in progress I guess but the code has been in production for a while and the task was actually to merge the library with another ironicaly enough (side note: I read before that as opposed to the related principle Seperation of Concerns, Single Responsibility does not encourage over seperation). There is very little structure or code in both repos as is, the code to be merged was a utils library and the the other repo was a broader sdk. So I guess it did make sense to merge the two. 

I didn't want to complete the merge without dealing with a broadly named class called 'utils'. I had problems with the name anyway as the lib already had utils in the name. I have heard it said many times before that if you can't think of a good name for a class then you should probably consider splitting it up. This was particularly true here – and so I did. The utils class essentially contained file upload and file download functionality. The code in itself had been ported from one language to another and so I would consider it a little hairy. It was essentially an untidied grouping of functions relating to the two purposes already mentioned.

The upload and download functionality shared very little in the way of common functionality – I would have been less inclined to touch the class if they did. The download relied on axios and the upload the s3 sdk (Javascript). The upload had a little more complexity around security whereas the download was from a standard url (usually a signed url but not always). In my opinion there is no advantage at all in having these two concerns threated as one. So I seperated and the code base is better for it hopefully.

One thing I didn't do was group the File download and upload functionality into a files module – I left them with other utils such as a retry calculator and page counter.  As I said before the code base is quite small and I didn't want to over engineer. Also I am aware that I work with others who are less keen on abrstactions and so I don't want to step on toes or be rude. Thats important too!

Cheers to WordPress

I have probably said it before but will say again … WordPress is great. I spend most of my day writing and reviewing code at work and is nice to be able to write in words for a change. 

Word press is built with PHP – I know PHP has it's critics and sure there is a lot of hacked together PHP scripts out there but I am sure there are is a lot of good code also. WordPress is it's real success story (sorry not a facebooker) in my opinion.

In the past I have dug into the code base and found it a little hairy (used to OOP) – this was years ago though. I don't know what it looks like now, and whatever about the code base the ui seems to be orgainzed very well.

WordPress is just so flexible and straight forward and is great fun. Not sure about using it for businesses to be honest – have been there before and I think eventually you out grow it. Small businesses should be fine!

Messaging Systems

Intro

Why use messaging at all ?

Recover-ability – if all else fails hopefully you will still have messages and once normal services have been restored, then you can proceed getting your systems back online, hopefully with minimal damage done.

Dealing with spikes in traffic – you want to make sure that you systems can handle load above it's capacity even if takes a long time to process each message.

There are probably other reasons also but those are two main ones I can think of right now.

Options

I have used a few and here is a brief discription of each and a comparison of their value. 

RabbitMq

Rabbit is written in Erlang. It is an interesting language and has the following characteristics, from wikipedia  – it is functional, fault-tolerant, highly available, soft-realtime (soft means tolerable if there is a delay in processing): https://en.wikipedia.org/wiki/Erlang_(programming_language)

It is also known for it’s pattern matching capabilities which I guess are useful with topics (more later) and above all I guess concurrency is it’s principal strength – which is great when you are dealing with millions of messages.

I once spoke to guy who programmed in Erlang and he seemed so engrossed in the language that I am sure he swapped English for Erlang and was speaking to me like so.

It uses a protocol called AMQP.

It also has many client libraries in Js, C# and many other languages which are pretty well implemented. This shouldn’t be taken for granted!

Messages are submitted to exchanges and queues are bound to the exchanges. You can have one to one relationships or indeed one to many.

Topics

You can submit with topics which ensures only the consumers with that specific topic receive those messages.  Subscribing to the relevant queue with the correct topic ensure that you only get messages you desire.

You can host yourself or use something like cloudAmqp.

SQS

To SNS or not to SNS

This is Amazons messaging system. Can be used in conjunctions with SNS or on it’s own. When used with SNS – SNS works as a sort of exchange and SQS as the queue.

SQS uses standard http underneath and offers a polling model for subscription. Is a little primitive in my opinion. The client libraries are also pretty basic although people are starting to build better libraries on top. With dotnet as an example though, easynetq is much more complete than any client offerings in SQS – we have had to essentially roll our own.

It’s not as sophisticated as something like RabbitMq. It’s strengths lie in it’s simplicity and it’s ability to scale, also the fact that hosting is taken care of by aws means we don’t have to worry about that side of things and also that it plays well with other AWS technologies such as lambda Dynamo db.

JMS

JMS is from the Java community and is an API specification as opposed to a protocol like AMQP. It can use a number of different protocols underneath – we use tcp in our implementation.

Coming from a dotnet background I found it a little difficult as had to consume using a c# library called NMS.

It has various implementations and the one I used was called ActiveMq. It us open source and relatively easy to install although creating and consuming messages is a little trickier.

Summary

All three options are useful depending on your needs. Rabbitmq probably has the nicest feature set but is not the easiest to get setup and started. Sqs is a better option if already using aws and I guess jms / active mq is nice for those who use Java. 

There are other options also such as Kafka but I would encourage you think if you really need the complexity of a messaging system before implementing as it does add it's own complexity.

Up the Deise !

Roy Keane once said Irish by birth, Corkonian by grace of god boy! I’m from cork myself but I have mixed blue blood in that my father comes from just outside the Waterford border in Tallow.

He is a keen supporter of the hurling and in particular the Waterford hurling team. When I was younger despite protesting that I was from cork and that I should be brought to see Cork play, I was brought to all the Waterford games instead.

This was in the early 90s and Waterford were not as good then as they are now. I remember dads clinched fist rise though when Waterford scored a goal better than anything else. I was quite young then but old enough to sense that it meant a lot to him.

I live in London these days and living abroad probably makes you more aware of where you come from in a sense. Ireland and the UK are next door to each other and so there is a keen rivalry when the two play in sports. It’s not particularly enjoyable to have to go into work surrounded by supporters of the other side either following a devastating defeat at their teams hands. Living and working in Cork all his life meant that dad has had to face the music on probably more than a few occasions but is fair to say he had last laugh (for the day) a few times also.

Also being married to a serious cork supporter was probably going to focus your supporting game. I’m not saying anything in particular only that a few flags have been known to go missing from time to time and accusations of unsporting supporting behaviour have been mentioned in the past also.

I also think that losing makes you a better and more loyal supporter. I don’t know why that is but I guess it proves you are there not just for the good times. Waterford have had their fair share of wins and losses over the years but there is probably no team more deserving of an all Ireland win in hurling the Waterford. Galway are funnily enough an other team that spring to mind, but I think no one would begrudge either side winning – even a Cork man close to the border.

There were so many great Waterford players over the last 10 years. Paul Flynn, Ken McGrath, Dan Shanahan, John Mullane and Tony Browne. I won’t say it is a crime that they didn’t win an all Ireland because crimes are for more serious matters. I won’t say tragedy either because no one died and it would be more of a tragedy if we started think like that. Sport should be for enjoyment alone – no room for tears. It is a pity though that they haven’t won an all Ireland at senior level since the 50s.

This is not the case under age though. The younger players have experience of winning and I think this shows in their play. Dan Shanahan seems to be doing a good job of adding his experience from the sides. So hopefully Waterford will have their day this September, they deserve it and so too does my dad!

When your 3ds freezes

I bought my 3ds about 5 years ago when I first moved to London.

Unfortunately I thought it had cooked it today when after searching high and low for it, Lex found it in the freezer! Amazingly it survived 24 hours at sub zero conditions.

I put it up on the radiator to taw it out and let it dry. I then googled ‘frozen 3ds’ to see if anyone else experienced the same thing and to see if I could find a prognosis. Then I have to admit I was surprised when I powered it on that it still worked!

I bought it from game around Oxford Street – which is one of the busiest shopping streets in world. It has been a great companion to me and has seen me through tick and thin. I feel it’s one big sign of wear and tear – it’s crack on the top right is a testament to what we have been through together.

For those who don’t know – a 3ds is the latest in the line of Nintendo handheld consoles which originated with game boy (or at least became famous). The switch is out now and is also portable and I’m planning on getting one of those at some stage but I still feel a connection and strong bond to my 3ds.

I bought mario kart first, then street fighter. I really got a lot of value from mario kart and played street fighter a little also. Then – I don’t know the exact order but I think it is…I got ocarina of time which is my favourite game of them all. Followed by majoras mask and possibly lylat wars. I got a link to the past and new super mario bros.

Lately, I have gotten into the virtual console which is all the old Nintendo games rereleased.

I was half way through Zelda links awakening, so am happy that i’ll get to finish that out! Nintendo games age so well.

So if you have frozen your 3ds and are wondering the chances of it working again then know that it did for me! I would leave it thaw out well though before switching it on and make sure water has evaporated.