服务定位器模式是一种软件设计模式。使用强抽象層封装了获取服务的过程。此模式使用称为“服务定位器”的中央注册表,它根据请求返回执行特定任务所需的信息。赞成者认为这简化了基于部件的程序开发,因为所有依赖在开发之初就清晰列出;而且运行时可灵活、动态可用资源而不必重新编译程序。批评者认为这是反模式,模糊了依赖,使程序难以测试。
参见
- 依赖注入
- 依赖反转原则
- JNDI
参考文献
外部链接
- [http://www.oracle.com/technetwork/java/servicelocator-137181.html Sample code]
- [http://bayou.io/draft/In_Defense_of_Service_Locator.html In Defense of Service Locator]
- [http://gameprogrammingpatterns.com/service-locator.html Game Programming Patterns: Service Locator]
- [https://thephp.cc/news/2015/09/dependencies-in-disguise Dependencies In Disguise]
- [https://github.com/azist/azos/blob/master/src/truisms.md Software Engineering Myths and Truisms]
评论 (0)