Skip to content

Month: September 2017

Why Service Locator is an Anti-Pattern?

Previously, we saw how we can use a Service Locator in order to prevent ‘newing‘ of objects in our code. However, everything comes with a price. Though we will talk about this in detail, but just to give you a gist of it, a service locator is an anti-pattern as it hides the class dependencies.   Commerce Application Example The example we are following is…

Using Service Locator Pattern in DI

To begin with, service locator pattern is one of the most commonly used pattern. In general, this pattern is used along with other patterns like Adapter Pattern, Observer Pattern, Dependency Injection Principles and many more. In this post, however, we will be talking about its use with dependency injection, which is one its many uses.   Introduction The service locator pattern works as a middle…

AsImplementedInterfaces – code with bad smell

While I was exploring Autofac, I found¬†AsImplementedInterfaces¬†quite interesting. Not only because it is useful, but also because if we are not careful with its use, we may end up with unexpected application behavior. However, it was quite difficult, to find an example which explains: what is AsImplementedInterfaces and how it helps? why code with¬†AsImplementedInterfaces has a bad smell? And therefore, here we are, with this…