Now that Windsor 3 is released I can concentrate on some of my other ideas and projects. While working on one of them, called Cartographer, I encountered an interesting API design problem.
I have a class (a builder to be precise) that has a task of setting up a central object (an IMapper implementation) in Cartographer (If you’ve ever used Autofac, it is somewhat analogous to ContainerBuilder). What is interesting about it, is I have three goals for that class:
- Provide API for high level configuration and extension points that are universal to and intrinsic to any IMapper implementation.
- Provide API for low level configuration of the default IMapper implementation that the builder creates, that will meet the following criteria:
- Not force user to customize anything, as the default setup should be enough to get started in most cases.
- Allow users to easily swap/extend parts of the dependency chain of the default mapper.
- Work well and be natural both with and without IoC container .
- Be simple and discoverable to the users (and provide good Intellisense experience).
How would you design the API for this class?
Oh, and happy new year.
I tried to partially reimplement Autofac Container Builder using Traits like system, unfortunately it has limitations due to extensions methods cannot be declared on generic class, because of that “As()” needs to be member of IRegistration interface.
For work in progress look here: https://github.com/Bobris/BTDB/tree/unstable/BTDB/IOC
It is really hard to really implement compile time mixins to have perfect intellisence with clean and extensible design.
Happy new year …
See the last part of this answer: http://stackoverflow.com/questions/2045904/dependency-inject-di-friendly-library/2047657#2047657
Provide the interface for high level configuration IConfiguration, provide second interface IDefaultMapperConfiguration implementing the IConfiguration with additional property DefaultMapper. The property would be responsible for low level configuration.
What I mean is to sth like Advanced property of the RavenDB session