Dependency Injection and the YAGNI principle

April 13, 2014

One of my new personal projects involves writing an application using Node.js and MongoDB. It's going to have a RESTful interface for the services, and MongoDB as the database (I haven't decided about what I'm going to use for the front-end, but Angular.js is a strong contender). I had looked at using mean.io to build it, but after playing with it for a while, it seemed to bring in too many things I wouldn't end up needing, so I decided to build it all from scratch using Restify for the RESTful services.

I'm writing it in an

Continue...

Logging Using EventEmitters in Node.js

January 15, 2014

I've been working a lot in node.js lately for a work project. Javascript as a language is an odd duck (pun not intended). It's got all these incredibly powerful features - dynamic typing, inheritance-by-prototype, functions as first-class objects - but it has some really odd anachronisms, including having to use the C-style for (var i = 0; i < length; i++) loop to iterate over arrays. Node adds a lot to the language as well, such as EventEmitters, which are very powerful. This afternoon I found a nifty new use for them: logging.

One of the issues that always seems

Continue...

Inheritance in Functional Languages

January 05, 2014

There's a tendency amongst proponents of functional languages, like Javascript, to consider inheritance an anachronism of older (and, by implication, worse) OO languages and OO design. One example is this discussion by Mikito Takada. This is what he says:

I think classical inheritance is in most cases an antipattern in Javascript. Why?

There are two reasons to have inheritance:

  1. to support polymorphism in languages that do not have dynamic typing, like C++. The class acts as an interface specification for a type. This provides the benefit of being able to replace one class with another (such as a function that

Continue...