Home  >  Article  >  Backend Development  >  如何理解 service locator 和 dependence inject

如何理解 service locator 和 dependence inject

WBOY
WBOYOriginal
2016-06-06 20:13:44868browse

暂时的理解是 (也不知道是不是这样):
di 就是用 反射实现的 ioc
service locator 就是结合了注册器模式和工厂模式(带记忆功能的工厂模式)

尽量用 PHP 的小例子说明, 感谢了

回复内容:

暂时的理解是 (也不知道是不是这样):
di 就是用 反射实现的 ioc
service locator 就是结合了注册器模式和工厂模式(带记忆功能的工厂模式)

尽量用 PHP 的小例子说明, 感谢了

https://github.com/domnikl/DesignPatternsPHP/tree/master/More

每天看一遍,直到恍然大悟。

学习设计模式是一个漫长的过程 《PHP设计模式》

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn