Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

中介者模式

中介者模式属于行为型模式,定义了一个中介对象来封装系列对象之间的交互。中介者使各个对象不需要显式地相互引用,从而使其耦合性降低,而且可以独立地改变它们之间的交互。

  • 应用场景

    系统中对象之间存在比较复杂的引用关系,导致它们之间的依赖关系结构混乱而且难以复用该对象。

    想通过一个中间类来封装多个类中的行为,而又不想生成太多的子类。

  • 优点

    降低了类的复杂度,将一对多转化成了一对一。

    简化了对象之间的关系,将系统的各个对象之间的相互关系进行封装,将各个类解耦,使得系统变为松耦合。

    符合迪米特原则。

  • 缺点

    中介者会庞大,变得复杂难以维护。

Morty Proxy This is a proxified and sanitized view of the page, visit original site.