Misconception: Constructor Injection Exposes Dependency Chains

I’ve struggled with explaining Service Locator as an anti-pattern. I’ve addressed certain cons of service locator and pros of constructor injection. However, I think I overlooked a fundamental misconception that would reasonably push developers away from constructor injection: a belief that constructor injection exposes dependency chains across the system.

June 24, 2022 · 4 min

Theory: Dependency Injection Scheme is Determined by Responsibility Layer

Scott Wlaschin posted an incredible series on dependency injection. It clarifies the different techniques and cases where each is useful. I noticed an interesting relationship between the techniques and the layers I use to categorize services.

October 24, 2021 · 3 min

Service Locator Hides Circular References

Many have discussed the issues with the service locator anti-pattern for dependency management. However, I’ve repeatedly run into an issue that I haven’t seen discussed yet: it causes circular references.

March 12, 2021 · 3 min