Skip to content

Facade

Context: Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher‑level interface that makes the subsystem easier to use.

public class SubsystemA { public void A1() { } }
public class SubsystemB { public void B1() { } }
public class SubsystemC { public void C1() { } }
public class Facade
{
private SubsystemA _a = new();
private SubsystemB _b = new();
private SubsystemC _c = new();
public void Operation()
{
_a.A1();
_b.B1();
_c.C1();
}
}

Order processing system: A OrderFacade calls inventory, payment, shipping, and notification subsystems in the correct order, hiding complexity from the client.

Example: In .NET, HttpClient provides a facade over lower‑level socket, DNS, and TLS components. Also, DbContext in EF Core is a facade over connection, command, transaction objects.