This chapter will be brief because the Service Locator pattern we will review is simple and efficient. The core idea of this pattern is straightforward: it revolves around having a central registry of initialized dependencies. But to be more precise, these dependencies are components that offer specific services that we can expose with interfaces we call "service contracts". Hence, when a client needs to call upon a particular service, it doesn't need to know how to localize and initialize it; it just needs to ask the Service Locator pattern, and this will do all the legwork to fulfill the service contract.
As we will see in this chapter, it's quite a simple design and is easy to implement.
In this chapter, we will cover the following topics:
- Understanding the Service Locator pattern
- Implementing...