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...

Using a Raspberry Pi as an iBeacon

November 15, 2013

There's an excellent blog post by by James Nebeker and David G. Young about simulating an iBeacon using a Raspberry Pi and a bluetooth dongle. Since I already had both, I thought I'd give it a try. It worked really well, and I've even put together the files necessary to do it in my GitHub repository.

You'll need to install BlueZ as well for this to work. Once you get it all installed and working you can use one of the mobile iBeacon apps, such as iBeacon Locate. Very fun to play with, and a good way to be able

Continue...

More Fun With BeagleBone Black

October 20, 2013

I've discovered that owning a BeagleBone Black (or, in my case, two) is kind of like owning one of those really, really nice
cars that you buy but you can almost never drive because it spends so much time in the shop. It's a lovely piece of hardware, it
really is, but the people who created it seem to have gone to great lengths to make sure that all you can do is sit back and admire
it, because you certainly won't be able to do anything useful with it.

My next foray into BBB craziness was attempting to get

Continue...

btle.js 0.2.0 released

October 19, 2013

I just (okay, a few days ago) released version 0.2.0 of btle.js to
npm. This has a bunch of API changes - the connect method now gives you a Device object, instead of a Connection. All the ATT methods are now on the Device object, but, in addition, you can access all the GATT functionality by querying the device for services, which returns Service objects, and services for
characteristics, which return Characteristics objects.

I'm also working on API docs for the whole thing.

Continue...