Web Client Software Factory Needs Service Registration via External Configuration File
by David Hayden ( Microsoft MVP C# ), Filed: Web Client Software Factory
I am a huge fan of the Web Client Software Factory. I better be since I will be presenting it at the Orlando Code Camp in 2 days :)
However, it is not perfect. Version 1.0 of anything is rarely perfect as you have to get something out there so you can get feedback from developers and find out where the Web Client Software Factory is a success and where it has missed the boat. I think the Patterns and Practices team did a heck of a job on it and I expect version 2.0 will knock our socks off based on current feedback and the current project roadmap.
Service Registration
One particular area I am disappointed in, however, is Service Registration. The Web Client Software Factory has Service Registration and Location built-in which is fantastic, but currently you can only register a local or global service programmatically in source code as follows:
protected virtual void AddModuleServices
(IServiceCollection moduleServices)
{
moduleServices.AddNew<CustomerDataAccess,
ICustomerDataAccess>();
}
I talk more about Service Registration in the following tutorial:
Registering and Using Business Module Services in the Web Client Software Factory
This means that whenever you want to change service providers for a service, CustomerDataAccess -> NewCustomerDataAccess, you need to modify source code, recompile, and publish the changes to the production environment. This limitation is counter intuitive to all the changes you see happening in ASP.NET, Enterprise Library, and the .NET Framework where you have the ability to swap out providers via a configuration file without having to touch source code and recompile.
A great example of this is the Membership, Role, and Profile Providers in ASP.NET that you can swap out easily in your web.config file. Every application block in Enterprise Library, which is used by all the Software Factories, has an extensive configuration section that allows you to change data access providers, logging providers, encryption providers, etc. via the configuration file with no change to source code. The list goes on.
Service Registration via Configuration File
What we need is the ability to specify services via a configuration file, and ideally I would want it to be supported by the Enterprise Library Configuration Editor :) I want something similar to Castle Windsor ( actually I want Castle Windsor :) where I can specify a service as follows:
<service
id="CustomerDataAccess"
service="ICustomerDataAccess, Core"
type="CustomerDataAccess, DataAccess"
lifestyle="singleton"
/>
Now when I want to switch CustomerDataAccess to NewCustomerDataAccess I just have to change the configuration file:
<service
id="NewCustomerDataAccess"
service="ICustomerDataAccess, Core"
type="NewCustomerDataAccess, DataAccess"
lifestyle="singleton"
/>
Simple. Elegant. Agile.
MonoRail with Windsor Integration
This is one of the areas where I think MonoRail and its Windsor Integration excels past the Web Client Software Factory. Windsor freaking ROCKS as I mention in a few posts:
Conclusion
IMHO, I think Service Registration via Configuration is a must have for version 2.0, but it certainly isn't the highest priority. However, if you are as passionate as I am about the success and well-being of the Web Client Software Factory, you may want to vote on this issue if you think it is important.
Service registration through configuration
See you at the Orlando Code Camp where I will be talking about the cool new application blocks in Enterprise Library 3.0 and the wonderful functionality in the Web Client Software Factory.
Source: David Hayden ( Microsoft MVP C# )
Filed: Web Client Software Factory