Facade pattern hides the complexities of the system and provides an interface to the client using which the client can access the system. This type of design pattern comes under structural pattern as this pattern adds an interface to existing system to hide its complexities.
This pattern involves a single class which provides simplified methods required by client and delegates calls to methods of existing system classes.
- 1️⃣ First Sub System
class SubSystemA
{
public void OperacionA()
{
Console.WriteLine("Operacion A");
}
}- 2️⃣ Second Sub System
class SubSystemB
{
public void OperacionB()
{
Console.WriteLine("Operacion B");
}
}- 3️⃣ Third Sub System
class SubSystemC
{
public void OperacionC()
{
Console.WriteLine("Operacion C");
}
}- 3 SubSystem in one Facade 🎩
class Facade
{
SubSystemA subSystemA = new SubSystemA();
SubSystemB subSystemB = new SubSystemB();
SubSystemC subSystemC = new SubSystemC();
public void OperacionAB()
{
subSystemA.OperacionA();
subSystemB.OperacionB();
}
public void OperacionBC()
{
subSystemB.OperacionB();
subSystemC.OperacionC();
}
public void OperacionAC()
{
subSystemA.OperacionA();
subSystemC.OperacionC();
}
public void OperacionABC()
{
subSystemA.OperacionA();
subSystemB.OperacionB();
subSystemC.OperacionC();
}
}- And Finally Client

static void Main(string[] args)
{
Facade facade = new Facade();
facade.OperacionAB();
Console.WriteLine(new string('-',50));
facade.OperacionAC();
Console.WriteLine(new string('-',50));
facade.OperacionBC();
Console.WriteLine(new string('-',50));
facade.OperacionABC();
Console.WriteLine(new string('-',50));
}- Output 👀
- Full project here
