Tutorials Design Patterns in C#
Facade Pattern — Complete Guide
Facade Pattern — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of Design Patterns in C# on Toolliyo Academy.
On this page
Design Patterns in C# · Lesson 10 of 69
Facade Pattern
GoF Core → Enterprise → Cloud & Craft
GoF Core · 1 — Create & structure · ~6 min · Module 2: Structural Design Patterns
What is this?
Facade offers a simple façade method over a cluster of subsystems so callers avoid wiring many services manually.
Why should you care?
ShopNest “PlaceOrder” touches stock, payment, and email — controllers should not orchestrate all three in detail.
See it live — copy this example
Paste into a C# console or class library project and run dotnet run.
public sealed class StockOps { public void Reserve(string sku) => Console.WriteLine($"reserve {sku}"); }
public sealed class PaymentOps { public void Charge(decimal amt) => Console.WriteLine($"charge {amt}"); }
public sealed class MailOps { public void Send(string m) => Console.WriteLine($"mail {m}"); }
public sealed class CheckoutFacade
{
private readonly StockOps _stock = new();
private readonly PaymentOps _pay = new();
private readonly MailOps _mail = new();
public void PlaceOrder(string sku, decimal amount)
{
_stock.Reserve(sku);
_pay.Charge(amount);
_mail.Send($"Thanks for {sku}");
}
}
new CheckoutFacade().PlaceOrder("HD-100", 4999);
Run Example »
Edit the code below and click Run to see the result in Toolliyo’s live editor.
What happened?
- CheckoutFacade sequences subsystems behind one method.
- Real systems inject dependencies and add transactions/sagas — the façade still keeps the entry point small.
Practice next
- Call PlaceOrder and read the three lines.
- Inject the ops via constructor.
- Keep controllers calling only the façade/use-case.
- Return an order id from PlaceOrder.
- Add try/catch and compensate reserve on charge fail.
Remember
Simple front door. Hide subsystem churn. Keep it thin over time.
ShopNest checkout façade
API endpoint calls PlaceOrder use-case/façade.
Outcome: Controller stays ~5 lines.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!