April 13, 2003
Follow me on Twitter

Tiny Types

Refactoring guru Martin Fowler has a nifty column in IEEE Software on When to make a type (pdf). His general advice:

On the whole, I'm inclined to say that when in doubt, make a new type. It usually requires little effort but often provides surprising results.

Proliferating types is not without a cost. I've been experimenting lately with interfaces between Tinderbox and Web services, looking at how one might use Tinderbox together with MovableType or the Google API. Error handling gets complicated when you're talking to another machine, using a fairly arcane and ad hoc protocol. The other machine might be down, or busy, or claim that you're talking nonsense, or its response might be nonsensical because it's decided to change its services. It's tempting to define lots of types for each step along the way, but then a mass of ad hoc protocol knowledge becomes a mass of ad hoc types. It can get ugly.