将适配器与外观一起使用
我的架构以前使用外观通过一组简单的方法来执行许多任务。就像:
startComputer(...)
shutdownComputer(...)
当我扩展应用程序时,我需要将多种类型的输入转换为外观本身。假设过去 startComputer
需要 6 个参数,而在新架构中,它需要某种可解析的字符串输入,而在另一种情况下,则需要一些 Base-64 编码的混乱。基本上,我想通过高级命令访问相同的子系统,但定义采用各种格式的接口。
当我开始考虑适配器与外观时,我感到很困惑——也许特别是因为人们总是在描述差异。在这种情况下,我本质上想要的(我认为)是使适配器支持各种输入,同时保持外观不变。在这种情况下,外观就是适应者。
这有意义还是有更好的方法?
My architecture previously was using a facade to perform a number of tasks through a simple set of methods. Something like:
startComputer(...)
shutdownComputer(...)
As I expand the application, I have the need to translate multiple types of input to the facade itself. Let's say that in the past startComputer
took 6 parameters, and in the new architecture it takes some sort of parseable string input, and in another case, some base-64 encoded mess. Basically, across the board, I want to access the same sub-system through high-level commands, but define interfaces that take all sorts of formats.
I get confused when I start thinking about adapters vs. facades -- maybe especially because people are always delineating the differences. In this case, what I essentially want (I think) is to make adapters to support various inputs while keeping the facade as is. In this case, the facade is the adaptee.
Does this make sense or is there a better way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来你希望你的外观使用“命令”模式来定义它的参数
http://en.wikipedia.org/wiki/Command_pattern
sounds like you want your facade to use the "command" pattern to define it's parameters
http://en.wikipedia.org/wiki/Command_pattern