现实生活中的非编程“实现”;设计模式的
我很难理解一些设计模式,特别是其中一些设计模式之间的差异,例如代理、委托和适配器。由于设计模式应该被发现,因此我试图在非编程世界中发现它们的“实现”。
ATM 机应该被视为银行的门面还是适配器?议会成员(在理想世界中)是代表模式还是代理人的例子?官僚主义是责任链的一个例子吗?股票市场是观察者模式的一个例子吗?战略模式的一个例子是什么?
您能否分享一下您为某些特定模式找到的类比?我正在寻找尽可能明确的例子。
我的目的是,如果可能的话,找到主流模式的示例,以有助于理解和在软件开发中应用的形式。
I am having a hard time trying to understand some of the design patterns, particularly the differences between some of them, such as proxy, delegate and adapter. Since design patterns are supposed to be discovered, I am trying to discover their 'implementations' in the non-programming world.
Should an ATM be considered a facade for a bank or rather an adapter? Is a member of parliament (in an ideal world) an example of a delegate pattern or a proxy? Is bureaucracy an example of chain of responsibility? Is the stock market an example of the observer pattern? What would be an example of the strategy pattern?
Could you please share the analogies you have found for some specific patterns? I am looking for examples which would be as unambiguous as possible.
My intent is to find, if possible, examples to mainstream patterns, in a form that would help in their understanding and application in software development.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
软件中的设计模式起源于建筑学。具体来说,模式语言一书。 wikipedia.org/wiki/Christopher_Alexander" rel="nofollow">克里斯托弗·亚历山大。虽然与 GOF“设计模式”一书中描述的模式不直接类似,但 Alexander 以相同的精神描述了现实世界中特定于设计的模式。
Design patterns in software have their origins in architecture; specifically, the book "A Pattern Language" by Christopher Alexander. While not directly analogous to the patterns described in the GOF "Design Patterns" book, Alexander describes patterns specific to design in the real-world in the same spirit.
有趣的问题。以下是我能想到的:
模板方法:我们遵循的某些仪式就是模板的示例。
工厂:这适用于任何制造部门。它生产商品并封装生产逻辑。
责任链:几乎所有需要办公室批准的事情都属于 COR 的范畴。
策略:航空公司预订政策是策略的现实示例。它因季节而异。
Singleton:作为一个人,我在宇宙中只是一个人:-)。所以我会是单身。
Interesting question. Following is what I could think of:
Template Method: Certain rituals that we follow would be example of Template.
Factory: This would apply to any manufacturing arm. It produces goods and encapsulates the logic of producing.
Chain of responsibility: Almost anything that needs approval in office falls under COR.
Strategy: Airline booking policies are a real world example of strategy. It varies from season to season.
Singleton: Me as a person is only one in the universe :-). So I would be singleton.