您的位置:首页 > 编程语言 > C语言/C++

C语言设计模式:代理模式、桥接与中介模式 //tbd

2013-02-11 18:56 615 查看
Proxy: Provide a surrogate or placeholder for another object to control access to it.

Bridge: Decouple
an abstraction from its implementation allowing the two to vary independently.

Mediator: 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.

代理这个词很好理解,代理模式在C语言中也很简单,如果接口封装了一个对象的功能,那么这个接口就是一种该对象的代理。

桥接和代理的区别是,代理的中间人是一个对象,代理即对中间人进行操作。而桥接是代理方法,并且不同的对象可指定不同的方法。在C语言中,这两种模式没有区别。

中介者模式,强调的是将对象间的通信转换为中介者的行为,从而实现对象和行为的解耦。

代码:TBD
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐