Facade设计模式,从Facade获取属性
我的应用程序中有类似外观设计模式的东西。我们可以这样开始: http://www.patternsforphp.org/doku.php?id=facade
来自示例:
外观=计算机
部件:CPU、内存...
这种情况的解决办法是什么:计算机有一个ID。大多数部件不需要知道计算机ID,但有几个部件与世界通信,例如。网卡,需要知道电脑ID放在哪。
该怎么办 - 最好的解决方案是什么?
感谢您的回复。
I have something like facade design pattern in my application. We can start this:
http://www.patternsforphp.org/doku.php?id=facade
From example:
Facade = Computer
Parts: CPU, memory...
And what is the solution this situation: The computer has an ID. Most of parts need not to know about Computer ID, but there is several parts, which communicate with World, eg. Network card, which need to know Computer ID in which is placed.
What to do - what is the best solution?
Thanks for replies.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我明白你想要这样的东西:
当您创建特定部件并将其私有存储在对象中时,您需要将computerId发送到特定部件。就像在网络驱动器中一样。
之后您可以根据需要使用computerId。
您可以使用观察者模式来通知 networkDrive 对象计算机 ID 的最终更改
if i understand you want something like this:
You need to send the computerId to the specific part, when you create the specific part and store it private in the object. Like in NetworkDrive.
After that you can use the computerId as you want.
You can use observer pattern to notify the networkDrive object for an eventual changing of computerId