Structure Map Fluent Interface
Now, I am not a user of StructureMap, but the interface looks cool:
registry.AddInstanceOf<IWidget>()
.WithName("DarkGreen")
.UsingConcreteType<ColorWidget>()
.WithProperty("Color").EqualTo("DarkGreen");
Jeremy calls it a DSL, but I don't think that it is the correct term, it is just using a diffeerent (and better) approach for coniguring it with code.
The main problem I have with this is that it is something that breaks down when you need the complex stuff, because you are working within the constraints of the compiler. I have worked quite a bit on the Rhino Mocks, and I have gotten very annoyed with the compiler at numerous occasions.
The problem with limiting yourself to the compiler is that you are forced to expressed declarative intention using imperation notation. The above using Binsor would be:
Frankly, I don't think that Jeremy's interface can get much better (short of starting to use Eq(), Lt() to make it shorter). I would rather step outside the confines of the compiler than stay within its limitations*.
* Yes, I know that there are a lot of people who would disagree with me on that one.
Comments
Comment preview