Service Locator Pattern In C#


Have you ever use ASP.NET membership provider? All ASP.NET developers know what is the membership and what is the membership provider. They can easily use one of the providers shipped with .NET framework, they can use a provider shipped with a certain product or they can build their own provider. The behind scene for this functionality is a design pattern called Service Locator. Service Locator Design Pattern is a very useful design pattern to make your software extensible and maintainable. Actually  there are many benefits push you to use this approach especially on the big systems as you can separate any part (Service) of your system and test it, re-implement it and deploy it without affect other running parts of the system because of the loosely-coupled relationship between Application and Service Implementation. We can summarize some its benefits as following:

  1. Perform unit-test in a easier way even on the production servers
  2. Make your Application extensible by a third parties
  3. Maintain your Application in a easier way
  4. Provide your customer by updates and hot-fixes that can be deployed without a complete new build

Continue reading