Service Location anti-pattern
The ideas behind the service locator pattern were first introduced by Martin Fowler around 2004, in a blog titled Inversion of Control Containers and the Dependency Injection pattern (http://martinfowler.com/articles/injection.html). Since then, this pattern has been built and field-tested in a number of different languages and environments. In his book, Dependency Injection in .NET, Mark Seeman argues that the Service Location pattern is in fact an anti-pattern.
Mark's reasoning is that it is too easy to misunderstand the usage of a particular class when Service Location is used. In the extreme case, each function of a class may use different services, which means that the user of the class needs to read through ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access