Design patterns
Design patterns, when used correctly can help to "craft" the software. However design patterns can easily make the code hard to understand too. So I guess there should always be a balance. My objective of this post is not to argue that Service Locator is an anti-pattern or not. My goal is just to write few lines of code and see how all fits together. I thought I will write a "form" of service locator that anyone can understand.
"Simple" Service Locator
The interface of the "simple" Service Locator looks like below:
I created a simple Console application that uses this Service Locator. The usage looks like below:
Limitations
A type must always implement an Interface.A type implementing multiple interfaces must be registered separately.
Only an interface can be registered against a type. ... etc etc, Many more.
If you interested in the code you can download it from GitHub.
No comments:
Post a Comment