Facade pattern comes under Structural design pattern.
It provides a unified interface to a set of interfaces in a subsystem.
Facade defines a higher-level interface that makes the subsystem easier to use.
Behaviour & Advantages
Simplifies the subsystem usage.
Acts as entry point to the subsystem.
Shields clients from subsystem components.
The interaction and communication among subsystems is hidden from client.
Provides a simplified API to interact with subsystems.
It knows how to handle a request and manages request processing with subsystems.
Complex set of classes designed to perform a specific task.
One who uses Facade to interact with subsystems.
This example shows a Compiler Facade which shield the users from
directly interacting with Subsystems such as Scanner, Parser, Assembler and Linker.
* The client deals with Compiler
* which generates the final executable.
* He does'nt need to know how
* Scanner, Parser, Assembler and
* Linker interact.
Compiler compiler = new Compiler();
It gives the following output,
Started scanning C:\random.cpp
Started parsing C:\random.cpp
Compiled to assembly c:\random.asm
Translated to binary object code c:\random.obj
Linked to executable c:\random.exe
Successfully compiled C:\random.cpp
Final executable is c:\random.exe