当前位置: 首页 > news >正文

一般产地证去哪个网站做郑州房产信息网查询系统

一般产地证去哪个网站做,郑州房产信息网查询系统,怎样做企业网站备案,wordpress 文章后台开多出资料框中介者模式是一种行为设计模式#xff0c;可以减少对象之间混乱无序的依赖关系。该模式会限制对象之间的直接交互#xff0c;迫使它们通过一个封装了对象间交互行为的中介者对象来进行合作#xff0c;从而使对象间耦合松散#xff0c;并可独立地改变它们之间的交互。中介者…中介者模式是一种行为设计模式可以减少对象之间混乱无序的依赖关系。该模式会限制对象之间的直接交互迫使它们通过一个封装了对象间交互行为的中介者对象来进行合作从而使对象间耦合松散并可独立地改变它们之间的交互。中介者模式又称为调停者模式。 Mediator is a behavior design pattern. It can reduce the disordered dependencies between objects. This pattern restricts direct interaction between objects, forcing them to collaborate through a mediator object that encapsulates the interaction behavior between objects, resulting in loose coupling between objects and the ability to independently change their interactions. 结构设计 中介者模式包含如下角色 Component组件基类声明组件的基本功能有一个指向中介者的引用该引用被声明为中介者接口类型。组件不知道中介者实际所属的类因此可通过将其连接到不同的中介者以使其能在其他程序中复用。 Mediator中介者接口声明了与组件交流的方法但通常仅包括一个通知方法。组件可将任意上下文作为该方法的参数只有这样接收组件和发送者类之间才不会耦合。 ConcreteComponent具体组件实现组件声明的方法并自定义业务逻辑接口。 ConcreteMediator具体中介者实现中介者接口声明的方法。 中介者模式类图表示如下 伪代码实现 接下来将使用代码介绍下中介者模式的实现。 // 1、中介者接口声明了与组件交流的方法 public interface IMediator {void notify(Sender sender); }//2、具体中介者实现中介者接口声明的方法 public class ConcreteMediator implements IMediator {Overridepublic void notify(Sender sender) {String message sender.getMessage();Component target sender.getTarget();target.operation(message);} }// 3、组件基类声明组件的基本功能有一个指向中介者的引用该引用被声明为中介者接口类型 public abstract class Component {protected IMediator mediator;public Component(IMediator mediator) {this.mediator mediator;}public void operation(String message) {System.out.println(message is message);}public void send(String message, Component target) {Sender sender new Sender(message, this, target);mediator.notify(sender);} }// 4、具体组件实现组件声明的方法并自定义业务逻辑接口 public class ConcreteComponentA extends Component {public ConcreteComponentA(IMediator mediator) {super(mediator);}Overridepublic void operation(String message) {super.operation(message);operationA();}public void operationA() {System.out.println(operationA in a Concrete ComponentA instance);} } public class ConcreteComponentB extends Component {public ConcreteComponentB(IMediator mediator) {super(mediator);}Overridepublic void operation(String message) {super.operation(message);operationB();}public void operationB() {System.out.println(operationB in a Concrete ComponentB instance);} } public class ConcreteComponentC extends Component {public ConcreteComponentC(IMediator mediator) {super(mediator);}Overridepublic void operation(String message) {super.operation(message);operationC();}public void operationC() {System.out.println(operationC in a Concrete ComponentC instance);} } public class ConcreteComponentD extends Component {public ConcreteComponentD(IMediator mediator) {super(mediator);}Overridepublic void operation(String message) {super.operation(message);operationD();}public void operationD() {System.out.println(operationD in a Concrete ComponentD instance);} }// 5、客户端 public class MediatorClient {public void test() {IMediator mediator new ConcreteMediator();Component componentA new ConcreteComponentA(mediator);Component componentB new ConcreteComponentB(mediator);Component componentC new ConcreteComponentC(mediator);Component componentD new ConcreteComponentD(mediator);componentA.send(i am a, componentB);componentB.send(i am b, componentC);componentC.send(i am c, componentD);componentD.send(i am d, componentA);} }public class Sender {private String message;private Component source;private Component target;public Sender(String message, Component source, Component target) {this.message message;this.source source;this.target target;}public String getMessage() {return this.message;}public Component getSource() {return this.source;}public Component getTarget() {return this.target;} }适用场景 在以下情况下可以考虑使用中介者模式 (1) 当一些对象和其他对象紧密耦合产生的相互依赖关系结构混乱且难以理解从而导致难以对其进行修改时可考虑使用中介者模式。中介者模式可将对象间的所有关系抽取成为一个单独的类 以使对于特定组件的修改工作独立于其他组件。 (2) 当组件因过于依赖其他组件而无法在不同应用中复用时可考虑使用中介者模式。应用中介者模式后 每个组件不再知晓其他组件的情况。尽管这些组件无法直接交流但它们仍可通过中介者对象进行间接交流。 如果希望在不同应用中复用一个组件则需要为其提供一个新的中介者类。 (3) 如果为了能在不同情景下复用一些基本行为导致需要被迫创建大量组件子类时可考虑使用中介者模式。由于所有组件间关系都被包含在中介者中 因此无需修改组件就能方便地新建中介者类以定义新的组件合作方式。 优缺点 中介者模式有以下优点 (1) 符合单一职责原则。可以将多个组件间的交流抽取到同一位置使其更易于理解和维护。 (2) 符合开闭原则。无需修改实际组件就能增加新的中介者。 (3) 可以减轻应用中多个组件间的耦合情况。 但是该模式也存在以下缺点 (1) 在具体中介者类中包含了组件之间的交互细节可能会导致具体中介者类非常复杂使得系统难以维护。一段时间后中介者可能会演化成为上帝对象。 参考 《设计模式 可复用面向对象软件的基础》 Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides 著, 李英军, 马晓星等译 https://design-patterns.readthedocs.io/zh_CN/latest/behavioral_patterns/mediator.html 中介者模式 https://refactoringguru.cn/design-patterns/mediator 中介者模式 https://www.runoob.com/design-pattern/mediator-pattern.html 中介者模式 https://www.cnblogs.com/adamjwh/p/10959987.html 简说设计模式——中介者模式
http://www.hkea.cn/news/14336636/

相关文章:

  • 万能引流软件衡阳做网站优化
  • 教育网站 网页赏析企业免费网站设计公司
  • 网站站内交换链接怎么做新手怎么搭建网站
  • 网站开发 产品经理wordpress 归档页面地址
  • 怎么做锅炉网站网站做优化有必要吗
  • 百度文库怎么做网站排名西安企业资本服务中心有限公司
  • 福清建设局网站中国经济网
  • 网站怎么做外链接地址西安搬家公司收费
  • 建设网站对公司起什么作用有那种网站么
  • 最新互联网项目平台网站婚庆租车
  • 信阳专业做网站公司青岛专业网站建设定制
  • 深圳建设网站个人wordpress做更改老是失败
  • 做军事网站的项目背景asp做的网站数据库在哪里
  • 长沙铭万做网站贵州seo和网络推广
  • 知己知彼网站网站经营跟备案不符
  • 全国网站建设企业专门做视频点评的网站
  • 经典企业网站模板建盏公司最新消息
  • 免费建建网站扬州公司做网站公司哪家好
  • 北京个人网站建设多少钱我局在网站建设方面
  • 教育网站制作实训报告东莞企业展厅设计公司
  • 怎么填写网站icp备案qq电脑版官网入口
  • 东莞百度搜索网站排名谷歌网页版
  • 做360手机网站优化有做翻译英文网站
  • 江苏省省建设集团网站学做预算有网站吗
  • 台州网站建设模板毕业设计网站怎么做
  • 物流网站模板深圳市设计院排名
  • 重庆做手机网站建设网站繁体和中文这么做
  • 做公司的网站大概多少钱新浪网站制作
  • 网站的网站建设企业南漳网页设计
  • 电商网站需求分析宜春市城市建设网站