April 2017
Intermediate to advanced
564 pages
24h 7m
English
Injection isn't the only way to loosen the components/service dependencies. Another way is to use the service locator.
Basically, a service locator is a sort of a registry object (a factory) that knows how to create the services or components that an application might need. For obvious reasons, this primarily shifts the burden of object creation from an individual class to the factory and we still have to get the locator object inside the classes using it, which results in the dependency of the locator itself.
We can also have more than one type of service locator inside an application. For example, FakeServiceLocator, whose purpose is just to provide the fakes that can be tested in the testing framework. ...
Read now
Unlock full access