Friday, January 13, 2017

Service Locator is an Anti-Pattern

Service Locator is an Anti-Pattern by Mark Seemann
Service Locator is a well-known pattern, and since it was described by Martin Fowler, it must be good, right?
No, it's actually an anti-pattern and should be avoided.
Let's examine why this is so. In short, the problem with Service Locator is that it hides a class' dependencies, causing run-time errors instead of compile-time errors, as well as making the code more difficult to maintain because it becomes unclear when you would be introducing a breaking change.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.