lec10_Mediator-Behavioral软件设计模式-体系结构.ppt

lec10_Mediator-Behavioral软件设计模式-体系结构.ppt

  1. 1、本文档共85页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Lecture 10. Mediator Pattern Behavioral mikesun725@ 189 0631 7629 0631 5687629 Contents of this lecture Introductory example to the mediator design pattern Theory of the Mediator Pattern Example design using the Mediator Pattern Implementation details of the Mediator Pattern Mediator Pattern-introductory example Mediator Pattern-introductory example Wang wants to build a house. Ask Li to setup base(call Li’s function of setup base) Ask Zhao to lay wall bricks (call Zhao’s function of lay wall bricks) Ask Huang to paste wall (call Huang’s function of paste wall) Problem: There are too many direct interactions Mediator Pattern-introductory example How to cancel so many interactions: Then a village head was elected, and all activities must be organized through the village head, who has the authority to ask the villagers to do things. Mediator Pattern-introductory example Mediator Pattern-introductory example public class VillageHead{ buildHouse{ Li.setBase(); Zhao.layBricks() Huang.pasteWall() } constructRoad{ Li.setBase(); Huang.mixCement() } } Mediator Pattern DESCRIPTION Generally, OO applications consist of a set of objects that interact with each other for the purpose of providing a service. This interaction can be direct (point-to-point) as long as the number of objects referring to each other directly is very low. Mediator Pattern Point to point communication of object A and object B Mediator Pattern As the number of objects increases, this type of direct interaction can lead to a complex maze of references among objects. Mediator Pattern Drawbacks of point to point communications The high coupling of so many objects Results in complex method calls affects the maintainability of the application (如果你要增加一个新的类,就太麻烦了) c) greatly reduces the scope for reusing these objects because of higher couplings Question: How to overcome the above problems? Mediator Pattern Mediator

文档评论(0)

东山书苑 + 关注
实名认证
内容提供者

业务以学生学习成长为中心,为外语培训、中小学基础教育、学前教育,提供各种学习资料支持服务。

1亿VIP精品文档

相关文档