The facade pattern is a structural design pattern that provides a single, simplified interface to a complex subsystem of classes, libraries or services. In software architecture, the facade sits between client code and the subsystem, accepts high-level requests such as placeOrder() and translates them into the many lower-level calls the subsystem actually needs.
The pattern was cataloged in 1994 in the book *Design Patterns* by the so-called Gang of Four, which defined its intent as making a subsystem easier to use. Its value lies in reducing coupling: clients depend on one stable entry point instead of on dozens of internal classes whose names, order of use and quirks may change.
How the facade pattern works
The facade pattern works by delegation. The facade class holds references to the subsystem components it needs and exposes a small set of methods that cover common use cases. Each facade method coordinates several subsystem calls in the correct order, passes data between them and returns a result in a form the client understands.
Importantly, the subsystem does not know about the facade. Its classes remain fully usable on their own, so advanced clients can bypass the facade when they need fine-grained control. The facade adds no new functionality of its own; it packages existing behavior behind a convenient boundary.
The participants of the pattern and their roles are summarized below.
| Participant | Role | Knows about |
|---|---|---|
| Client | Requests a high-level operation | Only the facade |
| Facade | Delegates and orchestrates calls | Selected subsystem classes |
| Subsystem classes | Perform the actual work | Each other, not the facade |
| Additional facade | Serves a different client group | An overlapping subset of classes |
Typical uses of a facade in software architecture
Facades appear wherever a rich, low-level API meets client code that needs only a few operations. Classic examples include wrapping a media library behind convertVideo(file, format), hiding a payment provider’s multi-step authorization flow behind charge(order) or exposing a compiler’s lexer, parser and code generator through a single compile(source) call.
At the architectural level, the same idea shapes layered systems. An application service layer often acts as a facade over domain objects and repositories, and an API gateway in a microservice system plays a similar role for external clients, aggregating calls to several services into one request.
| Scale | Facade example | Subsystem hidden |
|---|---|---|
| Class level | ReportExporter.export() | Formatter, renderer, file writer |
| Library level | A simplified HTTP client wrapper | Connection pools, retries, encoding |
| Module level | A billing module’s public service | Invoices, taxes, ledgers |
| System level | API gateway or backend for frontend | Multiple microservices |
Facade compared with adapter, proxy and decorator
The facade is often confused with other wrapper patterns, because all of them place an object in front of other objects. The difference lies in intent and interface shape: a facade defines a new, simpler interface for many objects, while the others work with a single object and either keep or convert its interface.
| Pattern | Wraps | Interface offered | Main intent |
|---|---|---|---|
| Facade | A whole subsystem | New and simplified | Ease of use, lower coupling |
| Adapter pattern | One object | Converted to an expected one | Compatibility |
| Proxy pattern | One object | Identical to the original | Access control, laziness |
| Decorator pattern | One object | Identical, with extra behavior | Add responsibilities |
| Mediator | Peer objects | Internal to colleagues | Coordinate interactions |
The contrast with the mediator is subtle. A mediator centralizes communication among objects that know it and talk through it, whereas a facade is invisible to the subsystem and only simplifies access from the outside.
Benefits and trade-offs of the facade pattern
The main benefit of a facade is a narrower dependency surface. When a third-party library is upgraded or replaced, only the facade has to change, and the rest of the codebase stays untouched. Facades also make code easier to test, because a client can be tested against a mock facade instead of a full subsystem setup.
The trade-off is reduced flexibility. A facade intentionally hides options, so clients with unusual needs either bypass it or push for new facade methods. That pressure leads to the best-known failure mode: the facade gradually grows into a god object that knows everything and violates the single responsibility principle from SOLID principles.
| Symptom | Likely cause | Remedy |
|---|---|---|
| Dozens of facade methods | One facade serves every client | Split into focused facades |
| Business rules inside the facade | Logic drifted out of the domain | Move rules back to domain classes |
| Clients bypass it everywhere | Facade is too restrictive | Review which use cases it covers |
| Leaky internal types | Methods return subsystem objects | Return facade-owned data types |
| Facade over a single class | Unneeded indirection | Remove it or use an adapter |
Designing a good facade
A good facade is designed from the client’s point of view, not from the subsystem’s structure. Start with the tasks clients perform, name methods after those tasks and keep the number of methods small. Dependency injection works well here: the facade receives its subsystem components through its constructor, which keeps it replaceable and testable.
- Keep the facade thin: it orchestrates, while rules stay in the subsystem or domain.
- Return simple data types or facade-specific objects so internal classes do not leak.
- Allow direct subsystem access for advanced cases instead of mirroring every option.
- Define the facade behind an interface when clients should not depend on a concrete class.
A non-technical view
Think of a hotel concierge. A guest who wants dinner, a taxi and theater tickets could call the restaurant, the taxi company and the box office separately, learning each one’s rules. Instead, the guest makes one request to the concierge, who handles all the calls in the right order.
The facade pattern is that concierge for software. It gives the rest of a program one simple desk to ask for help, while the complicated work still happens behind it. The guest can still call the restaurant directly if needed, but most of the time the concierge is simpler and less error-prone.
A concrete example
An online retailer’s checkout code originally called seven subsystem classes directly: inventory reservation, price calculation, tax lookup, payment authorization, order persistence, shipping label creation and email confirmation. The same sequence was copied into the web shop, the mobile backend and an internal phone-order tool, and each copy handled failures slightly differently.
The team introduced a CheckoutFacade with two methods, placeOrder(cart, customer) and cancelOrder(orderId). The facade performs the calls in a fixed order and releases reserved stock when payment fails. When the retailer later switched payment providers, developers changed one class instead of three code paths, and the change shipped in a single short release cycle without touching any client application.