☰ All patterns
Facade
One simple front door to a complicated system.
01
Explain it like I'm new
Real-life analogy
A hotel concierge
You tell the concierge 'I want dinner and a taxi at 8'. Behind the scenes they call the restaurant, the taxi firm and the front desk. You only talk to one person.
😩 The problem
Placing an order touches inventory, payments, shipping and email. Every caller has to know the right order of calls and handle each failure.
💡 The pattern
Create a type with one high-level method (PlaceOrder) that orchestrates the subsystems. Callers use the simple method; experts can still use the subsystems directly.
02
Walk through the code
Click a step to highlight its lines. This is a complete program you can copy and run.
Press ▶ Run to execute this program.This output was captured by running the program with Go 1.24. Copy it into your editor or the Go Playground and try changing things.
03
When should I use it?
✅ Reach for it when…
- •Complex subsystems most callers only use in one or two common ways.
- •Defining a clean service layer.
🚫 Skip it when…
- •The facade grows into a 'god object' that does everything. Split it up.
🐹 Go tip
Many Go 'service' structs are facades: they hold repositories and clients and expose business-level methods.
🌍 You've already seen it in
http.Get(url) hides Client, Transport, connection pooling and TLS behind one call.
04
Quick check
One question. No pressure.
http.Get(url) hides the Client, Transport and connection pool. That makes it a...