Dusty: A Micro-DSL for Castle Windsor

I’ve been spending more and more time thinking about how we over-engineer solutions and even libraries.  Currently my feeling is that NuGet and OpenWrap are only going to make this problem worse and not better.  The basic problem with buy versus build is that it’s posing the wrong choice.  Of course buy is cheaper than build.  But it’s like trying to chose between sparkling and still: the correct answer is tap.

A number of years ago I built a system that used Binsor for configuration.  Here were the benefits (to me):

  • Concise syntax
  • Programmable
  • Environmental Deltas

Of these, the first is nice to have, but not essential, the second is vital but can be achieved with the fluent configuration API.  It was only the third that Binsor offered that no other solution had.

Here were the costs:

  • Utterly undocumented.  Figuring out how to use a new facility was an exercise in hitting Google until it worked.
  • No-one else could understand it other than me.
  • It prevented me from using Windsor features it didn’t support.
  • The build and upgrade story was an absolute nightmare.

It took someone else to point out that, actually, Binsor was horribly over-engineered for what I actually needed.  Once I’d twigged to this, I realized that it was actually perfectly possible to knock together an alternative.  One that I could easily use to migrate away from Binsor while keeping the features I needed.  I did it in Ruby because, well, I like Ruby.  And I called it Dusty because I used to watch Ted Rogers when I was a kid.

Technical Details

So, it’s now up as a gist.  It’s in three parts.  The main part, dusty.rb is the main code and an example of how to configure it.  The examples are taken from real live running code, but are incomplete.  The delta file is a full valid environmental delta file.  The dusty.cs file just gives the two functions you need to call it.

Ideally, you wouldn’t even need IronRuby for this.  However, it does make the configuration syntax nicer at the cost of some initial setup.  The configuration syntax, as you can see, is deliberately close to Binsor’s, precisely because I was using it to enable a migration away from Binsor.

You’ll note that the only reuse method this supports is Joe Walnes’ favourite technique.  If you need the container, you can just access it directly.  If you need a new feature, just change the code.  And if you don’t need it, don’t use it.

Technorati Tags: ,

Published by

Julian Birch

Full time dad, does a bit of coding on the side.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s