The service locator pattern encapsulates the processes involved in obtaining a service with a strong abstraction layer. The pattern uses a central registry known as the "service locator", which on request returns the information necessary to perform a certain task. The pattern is often considered an anti-pattern, because it hides the dependencies of class (in contrast to constructor injection).
- Related patterns
Dependency Injection: The Service Locator pattern is one of the many Dependency Injection patterns that allow us to create loosely-coupled code.