Question

Service Locator seems like a pretty useful concept and I'd like to implement it in my app. However, I have a few questions about how it should be implemented and how it should be used in conjunction with other programming paradigms.

  1. Should the SL manage the service it is storing? That is, when the SL gets destroyed, should it also destroy the service itself, or should it leave that to whoever registered the service?

  2. What about Dependency Injection? Now that I have an SL is there any point in passing the SL around as a parameter or should I access it globally? After all, much of the whole purpose of DI is covered by SL as well, and I wouldn't like to clutter a lot of my functions with one more parameter.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top