Skip to content

Commit eb4ed6b

Browse files
author
Dominik Liebler
authored
Merge pull request DesignPatternsPHP#252 from 0x13a/master
service locator is anti-pattern
2 parents 4d13466 + 9206851 commit eb4ed6b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

More/ServiceLocator/README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
`Service Locator`__
22
===================
33

4+
**THIS IS CONSIDERED TO BE AN ANTI-PATTERN!**
5+
6+
Service Locator is considered for some people an anti-pattern. It violates the Dependency Inversion principle.
7+
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.
8+
49
Purpose
510
-------
611

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ The patterns can be structured in roughly three different categories. Please cli
8686

8787
### [More](More)
8888
* [Delegation](More/Delegation) [:notebook:](http://en.wikipedia.org/wiki/Delegation_pattern)
89-
* [ServiceLocator](More/ServiceLocator) [:notebook:](http://en.wikipedia.org/wiki/Service_locator_pattern)
89+
* [ServiceLocator](More/ServiceLocator) [:notebook:](http://en.wikipedia.org/wiki/Service_locator_pattern) (is considered an anti-pattern! :no_entry:)
9090
* [Repository](More/Repository)
9191
* [EAV](More/EAV) [:notebook:](https://en.wikipedia.org/wiki/Entity%E2%80%93attribute%E2%80%93value_model)
9292

0 commit comments

Comments
 (0)