Skip to content
Commitwise
Menu

Facade pattern

One simple class in front of a group of classes, offering a few high-level methods for the common tasks.

Definition

A facade coordinates a subsystem (several services that must be called in the right order) behind methods named after what callers want, such as placeOrder(cart). It owns the sequence of steps and what happens when one fails, but holds no business rules of its own. The subsystem stays available for callers that need more control. A facade that collects every method of every subsystem turns into a god object.

In practice

CheckoutFacade.placeOrder reserves stock, charges the card, creates the order and releases the stock if payment fails.

Related terms

Esc

Type to search the whole site.