简体   繁体   English

如何正确设计适配器模式

[英]How to properly design an Adapter pattern

I have an Application where I want to Implement an Adapter pattern. 我有一个应用程序,我想实现一个适配器模式。 I have different types of sources for which there are different Adapter and there can be multiple sources of single type . 我有不同类型的源 ,有不同的适配器,可以有多种单一类型的来源 The question is do I instantiate a single Adapter for each type or individual sources? 问题是我是否为每种类型或单个来源实例化一个适配器? Also why? 还为什么呢?

For each source, you would want to create an instance. 对于每个源,您可能希望创建一个实例。 If several sources are of the same kind, you would probably create several instances of the same Type. 如果多个源是同一类型,您可能会创建多个相同类型的实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM