The Facade design pattern is used to create a united interface for an entire logical group of classes representing a subsystem.
We often work with several interfaces of different classes in our application. This can often be confusing, especially if these class interfaces are complex. If the classes are logically related, we can group them into a subsystem using Facade. This gives us a unified interface for the functionality provided by the subsystem.
Facade is a fairly simple pattern that consists of a single class forming the facade. It's connected to other classes which it works with. However, from the outside, only the facade is visible (that's the reason why it's called this way), and it represents an interface for the entire subsystem. The whole complex structure of the classes is in the background.
The number of classes we communicate with is reduced. The subsystem is easier to use and test. It's a mediator again and there is some similarity to the Adapter (Wrapper) pattern. However, we wrap multiple classes into one logical subsystem.
An example could be a facade for working with PC at the hardware level. It would group a class that allows the computer to sleep, restart, or shut down. Then, a class that would adjust the brightness of the monitor and another one, that would read processor and disk temperatures. The facade would unify all the methods into a single interface. It could contain only methods we selected for our purposes.
The advantage of the pattern is also resolving dependencies of individual components of the subsystem. If we pass an instance between them, it's done inside the facade.
No one has commented yet - be the first!