Facade pattern

Facade (English facade ) is a design pattern in the field of software development and belongs to the category of structural patterns ( structural design patterns ). It provides a unified and most simplified interface to a set of interfaces in a subsystem.

If a subsystem contains many technically oriented classes that are rarely used outside, it helps to use a facade. The facade is a class with selected methods, including a frequently used subset of functionality of the subsystem. It delegates the functionality to other classes of the subsystem, thereby simplifying the management of the subsystem.

Advantages and Disadvantages

The facade promotes loose coupling, because multiple interfaces are merged into one, and reduces the complexity because it hides the underlying subsystem. Besides, the subsystem can be easily extended by the loose coupling.

The disadvantage is that an additional indirection is introduced.

Example

The standard library of Java contains many classes for the processing of fonts and their representation as geometrical figures or directly as pixels. However, most Java programmers never come in contact with these classes because the standard library with the facade classes Font and Graphics very easy access to the main font operations granted.

Structure

Related design patterns

The Abstract Factory ( Abstract Factory, Kit) can be used together with a facade in order to provide an interface for creating a system object independently of the subsystem.

The mediator ( mediator) is just like the facade as an intermediary between classes to avoid direct traffic.

The adapter ( wrapper ) is a changed interface to an existing class or a subsystem ready.

Business Delegate is the counterpart of the facade on the calling component.

324245
de