Wednesday, 31 August 2016

Design Pattern Haikus


a singleton is
a global variable
sounds a bit better 

A singleton is just a fancy name for a global variable. I like to think of a singleton as a way of warping to another point in space/time, changing the space time continuum and then heading back. You've seen the sci-fi films where this happens, right? It has similar effects on your code, making it difficult to understand what the hell is happening.


interpreter is
domain specific language
that is all it is

Well, there's not much more to say is there? You want your code to be readable in the language of your domain. One way to do this is to make the code look more like the language of your domain. A domain-specific language is one way to accomplish this.


multiple dispatch
that is what you really wanted
visitor will do

You've got a function that wants to do different things depending on the types of the arguments. You've got a language that only allows you to do one different thing via polymorphism. You don't want type-switching cos someone told you that was bad.

Assuming you've got those prerequisites then go for the visitor pattern. Alternatively, look at multiple dispatch and see there's no problem there at all really.


functions compose well
classes do not compose at all
love strategy pattern

You want to break apart a set of work into small discrete components (let's call them "objects"). The strategy pattern allows you to plug these together to solve a problem.

Or... You want to break apart an algorithm into discrete functions (let's call them functions). Functions glue together.

Wednesday, 11 May 2016

Professionalism in Software Engineering

Yesterday, I attended a talk by Bob Martin on Professionalism in Code hosted by Software East at Redgate. I also spent considerable time beforehand working out whether it'd be unfair to introduce Bob as the "Donald Trump of Computer Programming". Sanity prevailed and I didn't. But I just wrote it up there, didn't I? D'oh.

Is the software engineering industry professional? As software engineering professionals we should have skill and good judgement. Does the software engineering industry have that?

Bob gave the famous example [PDF] of Knight Capital and Volkswagen, but there's many more (Therac-25, the F35 and The Chaos Report [PDF]). You could argue that the software industry is in meltdown and developer incompetence / poor judgement has cost the industry billions. I think you'd have a pretty convincing case! Or would you? There was no mention the other side - the tremendous advantages our haphazard industry has made to almost the whole planet (the Internet, mobile phones, communication).

Bob painted the nightmare scenario - regulation. Imagine some time from now, some bug somewhere (a missing ; even) results in a number of deaths. The nuclear reactor blows, the self-driving cars go made on a leap year and start running people over, the planes turn upside down when crossing the equator (etc). The natural result of this is the Government blames us (software developers) and starts to put some regulations in place. Again, this feels believable-ish.

But why hasn't it happened yet? Well, safety-critical systems are pretty regulated. See this lump [PDF trigger warning] from the FAA about how they do things. I'm not going to argue it's perfect, but it's demonstrably good enough to stop null pointers making things fall out the sky regularly.

So what should we do to prevent this threat of regulation? Well, we should:
  • Not ship shit!
  • Give reasonable estimates!
  • QA should find no bugs
  • Software should get better, not worse
  • Invest 20 hours per week in personal development
Most of this stuff is easy to agree. Of course we shouldn't ship shit - are you insane? Of course we should strive to write bug free code. If you want to explore these ideas more, Bob's book (The Clean Coder) covers the topics in much greater detail. It was a great talk and got the audience thinking.

Are these the right things to make the industry professional? Maybe. Maybe as an industry we should look at other areas:
There's a huge space for software engineers to explore about building professional quality software. We're not explored much yet. I'm certainly no historian, but I'd imagine professions like Medicine, Law and Engineering took more than 60 or so years to establish what good looked like.

The deliciously chaotic world of software engineering is going to continue for a while yet!

Monday, 4 April 2016

Azure Platform Services

Last time around we compiled a large compendium of links detailing Azure Infrastructure services. In this post, we'll compile an even larger set of links detailing Azure's Platform Services (PaaS rather than IaaS).

The breadth of services that Azure offers is pretty overwhelming, so take a deep breath :)

Cloud Compute

Azure Cloud Services allows you to create a compute service (ASP.NET, Python, node and PHP are all supported). This might be a worker role (e.g. a background tasks) or a web role (e.g. simple requests to display data). Cloud Services gives you the ability to scale these horizontally as needed.

Azure Batch runs your large scale parallel tasks and big batch processing jobs. Azure scales these as needed.

Azure Service Fabric is an orchestration layer for micro-service based deployments. It was borne out of internal use at Microsoft used to develop Azure itself.

Azure RemoteApp is a bridging technology (similar to Citrix type things) allowing you to access your application anywhere.

Web and Mobile

Web App Service allows you to deploy web applications in languages like C#, node.js and Python. It's now part of the more general Azure App Service.

API App Service allows you to deploy secured API services and generate appropriate clients to access them.

API Management Service lets you "take any API and publish a service in minutes". More specifically you get monitoring, RESTful and JSON-ful support and the ability to combine multiple back-ends into a single API endpoint.

Mobile App Service gives you an API specifically for mobiles, including support for off-line sync.

Logic App Service lets you integrate business processes and workflows visually. It's goal is to make it easy for you to join your data from on-premise to cloud-based workflows.

Notification Hubs provide scalable push-notifications to all major platforms (including iOS and Android).


SQL Database provides a fully managed PaaS version of SQL Server with advanced features such as an index advisor (monitoring your workload to see access patterns that would benefit from an index).

SQL Data Warehouse is a data warehouse that can scale to huge volumes of data (pricing is based separately on Compute and Storage use).

Redis Cache is the PaaS version of Redis, an in-memory data structure store.

DocumentDB is a store for JSON documents. As of Build 2016, it was announced that there is a MongoDB compatibility layer (see here).

Azure Search provides a fully managed search service (with Lucene query compatibility).

Azure Table Storage provides you with a key-value store aimed at large schema-less documents.

Analytics and IoT

HDInsight is a managed Apache Hadoop (map/reduce), Spark, R, HBase and Storm service made "easy".

Azure Machine Learning is a set of machine-learning API's, allowing you to applying advanced analytics to a wide source of data (pictures, people, text etc.). As of Build 2016, this seems to be in the process of being rebadged "cognitive services".

Azure Stream Analytics gives you the ability to do real time processing of streaming data from huge numbers of sources.

Azure Data Factory is a set of data orchestration API's, allowing you to mangle data from different sources together (with tools for data lineage, ETL and so on).

Azure Event Hubs is a scalable pub-sub service for aggregating events from many sources.

Mobile Engagement is a set of API's for monitoring and understanding app usage on mobile devices.