中介者模式
来源:互联网 发布:AEditor源码 编辑:程序博客网 时间:2024/04/29 18:27
中介者模式,看字面就知道什么意思了,业务对象太多的时候,每个业务对象又需要建立交流,如果各个业务对象之间都自己去建立交流的话,结果就会很杂乱,比如9个对象,每个对象之间建立一个交流的线,那就是9以2做组合,8*9/2=36条线。但是引入中介者之后,结构就非常清晰了,每个对象要和其他对象交流只需要传达给中介者,中介者会和其他对象交流后返回给你,由中介者对象把每个对象之间的交互封装起来就可以了,此时就只需要9条线就完成了,也减小了耦合度。英文释义:Define an object that encapsulates how a set of objects interact.Mediator promotes loose coupling by keeping objects from referring to each other explicitly,and it lets you vary their interaction independently.
示例:
中介类:
public class Mediator{
protected Business1 busines1;
protected Business2 busines2;
protected Business3 busines3;
public Mediator(){
busines1=new Business1();
busines2=new Business2();
busines3=new Business3();
}
public void execute(){
switch(){
......
}
};
}
业务类:
public class Business1{
Mediator mediator=new Mediator();
public void dobusiness1(){
mediator.execute();
}
}
- 深入浅出中介者模式
- 中介者(Mediator)模式
- Mediator中介者模式
- 中介者模式
- 中介者模式
- Mediator 中介者模式
- 中介者模式Mediator
- 侃中介者模式
- 中介者模式
- 中介者模式 MediatorPattern
- 中介者模式Mediator
- 中介者模式
- 中介者模式
- 中介者模式
- 中介者模式
- 中介者模式
- 中介者模式(python)
- Mediator模式(中介者)
- rsync: failed to set times on "/." (in ftp): Operation not permitted (1)
- Java中URLDecoder的编码问题
- hdu 5399(数学推理)
- JavaScript 回调(callback)函数
- ie内核相关网址记录
- 中介者模式
- NYOJ264国王的魔镜
- 《第一行代码》读书笔记(第一章,第二章)
- 拓扑排序
- 简单工厂模式,工厂模式【Factory Pattern】,抽象工厂模式
- 自行车_纪中1238_缩点+拓扑排序+递推
- Python核心编程----Python对象
- Struts2的简单使用(一)
- 螺旋矩阵