JNarrate – Andy Palmer https://andypalmer.com Views on software, technology, consulting and business process Thu, 02 Jul 2009 15:32:43 +0000 en-US hourly 1 https://wordpress.org/?v=6.4.3 Tiny Types https://andypalmer.com/2009/07/tiny-types/ https://andypalmer.com/2009/07/tiny-types/#respond Thu, 02 Jul 2009 12:29:32 +0000 http://andypalmer.com/?p=171 Mark Needham’s post on micro types sparked an idea in my head that recently came to fruition.
I was pondering on the Narrative Fixture code, and the fact that, although most of the internals are sensibly typed objects, at the FitNesse layer, we do a lot of passing of strings.
The idea (at least, my interpretation) with Tiny Types is that the string obviously means something, and that we can probably classify what that meaning is (we have a sensibly named variable for it, after all) , and so why not convert it to that meaningful thing as soon as possible.
This has the nice effect of making some vague things (such as typing on collections) much more explicit.

As an example, in the Casting Director we have:

Map<String, ActorPlayingThe<?>> dressingRoom = new HashMap<String, ActorPlayingThe<?>>();

and, after a little bit of refactoring, we end up with:

Map<CharacterName, ActorPlayingThe<?>> dressingRoom = new HashMap<CharacterName, ActorPlayingThe<?>>();

Personally, I’m a fan of low ceremony, high essence languages, but while working in a high ceremony environment, we can leverage that ceremony to provide us with a nice summary of our thinking, ready for the next time we return to the code.

]]>
https://andypalmer.com/2009/07/tiny-types/feed/ 0