你能解释一下吗Extension Object Pattern以及它与适配器模式有何不同?
Web 中似乎只有很少的资源可以解释扩展对象模式,而且其中大多数都有些令人困惑(至少对我而言)。
提前致谢。
最佳答案
主要区别在于使用时间:
您将在软件开发过程中使用适配器,以防您无法更改引入适配器的现有接口(interface)。
扩展对象模式提供了此类更改,并使您能够例如扩展已经部署的软件。
另外,从您发布的文本中:
Adapter supports to adapt an existing interface. The Extension Objects pattern supports additional interfaces. Extension Objects and Adapter can work together in situations where an object needs to be adapted to an extension interface.
关于design-patterns - 扩展对象模式和适配器模式有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39331752/