Class hierarchy design

For the love of all that is dear to software development avoid parallel but separate class hierarchies. Today we’re going to talk a little bit about type hierarchy design and why composition is useful to consider in certain scenarios. ...

February 20, 2016 · MichaelHughes

NodeJS counter implementation

Performance counters can be implemented in applications to help operators determine where bottlenecks are in the design. Microsoft has a decent page, that’s somewhat Windows centric, about performance counters. This post is about implementing the most basic type of counter, a value which monotonically increases, in JavaScript for NodeJS and the performance implications of different designs. ...

February 20, 2016 · MichaelHughes

NodeJS modules should export object constructors

Note I didn’t say always should export objects, but for the sanity of everyone involved, in many cases a required module should return a constructor and not a fully instantiated object. Today’s post is about why your NodeJS modules should look like this: /** * @constructor */ function myConstructor(someDependency) { /* setup my object here */ } module.exports = myConstructor; and not this: var myObj = { myService: new MyService() }; myObj.myFunction = function(foo) { /* do stuff with foo here */ }; module.exports = myObj; ...

October 3, 2015 · MichaelHughes

Logging and Monitoring

Operational monitoring of a software application is one of the activities the ensures a successful public launch. Too often it seems like a service’s course to public availability looks something like, Conceptualization → Development → … → SHIP IT. The “…” component is an important step at large enterprises with large public services (like Expedia, Amazon.com, etc) and involves developing a way to monitor an application whilst running it. At smaller organizations though I have seen this smaller step get discarded or not looked at. Today’s post offers a few thoughts on what logging and monitoring looks like today. ...

June 28, 2015 · MichaelHughes

SRV records as service locators

Recently I began work on a project to manage the deployment of a product built using a microservices architecture. As a result of our chosen architecture we have a large number of services which will communicate to each other over HTTP/S. Instead of using fixed IPs we decided to used DNS SRV records to indicate where services could contact their dependencies. Today’s post goes into using SRV records in a little more detail and the problem they solve. ...

May 2, 2015 · MichaelHughes

Loops in NodeJS

I’ve written before about how it’s better to write straightforward code than trying to be clever and pre-optimize. Another example of where this rule is true is the cost of iteration between different styles of array loops in JavaScript when executed within NodeJS. ...

March 15, 2015 · MichaelHughes

Repository pattern overuse: The double repository with Microsoft Entity Framework and other ORMs

Martin Folwer’s blog and website is a common reference for modern design pattern so we will start with his glossary definition for the repository pattern. The linked article contains more detail, but in short a ‘repository’ acts as an data store layer on top of the storage system and provides (more) object oriented methods for accessing said system. Unfortunately, something I have also seen is the over application of this pattern in combination with RDBMS ORMs leading to contorted code with unnecessary interfaces and classes. This post covers what I have seen in some projects in order to provide some of the code smells to avoid. ...

January 4, 2015 · MichaelHughes