What is the Facade pattern?
Quick Answer
Facade provides a single, simple interface over a complex subsystem of many classes. The client calls orderFacade.PlaceOrder(cart) and the facade coordinates the inventory service, pricing engine, payment gateway and notification service behind the scenes.
A facade is a simple front door to a complicated set of classes. Placing an order might involve checking stock, calculating price, taking payment, and sending a confirmation — several services. The facade exposes one PlaceOrder method and coordinates all of that internally, so the controller doesn't have to know the orchestration. In a layered app, the application-service layer is basically a bunch of facades, one per use case. The difference from an adapter is that a facade simplifies whereas an adapter changes an interface to match what a client expects.
- An application service in a layered architecture is essentially a facade — it orchestrates domain objects and infrastructure for one use case.
- Doesn't hide the subsystem completely — advanced callers can still use the underlying classes directly.
- Facade vs Adapter: facade simplifies (many → one, same-ish concepts); adapter translates (one interface → a different expected interface).