门面模式(Facade Pattern)
定义:Provide a unified interface to a set of interfaces in a
subsystem.Facade defines a higher-level interface that makes the
subsystem easier to
use.(要求一个子系统的外部与其内部的通信必须通过一个统一的对象进行。门面模式提供一个高层次的接口,使得子系统更易于使用。)
门面模式(facade)又称外观模式。
组成:
- 门面角色(facade):这是门面模式的核心。它被客户角色调用,因此它熟悉子系统的功能。它内部根据客户角色已有的需求预定了几种功能组合。
- 子系统角色:实现了子系统的功能。对它而言,facade角色就和客户角色一样是未知的,它没有任何facade角色的信息和链接。
- 客户角色:调用facade角色来完成要得到的功能。
举例:
Facade 模式的一个典型应用就是进行数据库连接。一般我们在每一次对数据库进行访
问ÿ