Questions tagged [service-locator]

The service locator is a design pattern that aims at decoupling the use of an abstract services from concrete implementations of these services. This pattern encapsulates the determination of the concrete implementation to use and implements the principle of dependency inversion.

Filter by
Sorted by
Tagged with
111
votes
5answers
9k views

What's the difference between using dependency injection with a container and using a service locator?

I understand that directly instantiating dependencies inside a class is considered bad practise. This makes sense as doing so tightly couples everything which in turn makes testing very hard. Almost ...
4
votes
2answers
5k views

IoC containers and service locator pattern

I am trying to get an understanding of Inversion of Control and the dos and donts of this. Of all the articles I read, there is one by Mark Seemann (which is widely linked to in SO) which strongly ...
1
vote
1answer
959 views

Is this a good service locator, and is this service locator pattern(?) OK?

I'm working in Zend framework 1 and was using Zend_Registry to store objects so that I could replace them in my controllers while unit testing: $auth = Zend_Registry::get('Auth'); // set in Bootstrap....