From 9206851f215a98c1f9b24d9d20c27bbd1ee65c75 Mon Sep 17 00:00:00 2001 From: Diego Mariani Date: Tue, 29 Nov 2016 10:47:13 +0100 Subject: [PATCH] service locator is anti-pattern --- More/ServiceLocator/README.rst | 5 +++++ README.md | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/More/ServiceLocator/README.rst b/More/ServiceLocator/README.rst index 31fc6f0..050f7bc 100644 --- a/More/ServiceLocator/README.rst +++ b/More/ServiceLocator/README.rst @@ -1,6 +1,11 @@ `Service Locator`__ =================== +**THIS IS CONSIDERED TO BE AN ANTI-PATTERN!** + +Service Locator is considered for some people an anti-pattern. It violates the Dependency Inversion principle. +Service Locator hides class' dependencies instead of exposing them as you would do using the Dependency Injection. In case of changes of those dependencies you risk to break the functionality of classses which are using them, making your system difficult to maintain. + Purpose ------- diff --git a/README.md b/README.md index d21efab..de2c4f6 100755 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ The patterns can be structured in roughly three different categories. Please cli ### [More](More) * [Delegation](More/Delegation) [:notebook:](http://en.wikipedia.org/wiki/Delegation_pattern) -* [ServiceLocator](More/ServiceLocator) [:notebook:](http://en.wikipedia.org/wiki/Service_locator_pattern) +* [ServiceLocator](More/ServiceLocator) [:notebook:](http://en.wikipedia.org/wiki/Service_locator_pattern) (is considered an anti-pattern! :no_entry:) * [Repository](More/Repository) * [EAV](More/EAV) [:notebook:](https://en.wikipedia.org/wiki/Entity%E2%80%93attribute%E2%80%93value_model)