外观模式

发布时间 2023-06-03 21:43:42作者: 云霄宇霁

The Facade  design patten provides a unified interface to a set of interfaces in a subsystem.This pattern defines a higher-level interface that makes the subsystem easier to use.

外观模式为子系统一组接口提供了统一的接口,这种模式定义了高级接口,便于子系统调用。

UML Class Diagram

 

Facade:

  • Knows which subsystem classes are responsible for a requst 
  • Delegates client request to approciate subsystem objects.

Subsystem classes

  • Implement subsystem functionality
  • Handle work assigned by the Facade object.
  • Have no knowlege of the facade and keep no reference to it.

When to use Facade Design Pattern in Real-Time Application?

  • We want to provide a simple interface to a complex subsystem.
  • There are many dependencies between clients and the implementation classes.