Skip to the content.

Facade

The problem

Checking out involves three subsystems in a strict sequence: verify stock, reserve it, charge the customer, book the courier. If every caller (web checkout, phone orders, the till in the physical shop) orchestrates this by hand, the sequence is duplicated everywhere – and one caller forgetting the stock check before charging is a refund waiting to happen.

The pattern

A facade offers one intention-sized method and keeps the subsystem choreography inside:

CheckoutSummary summary = checkout.checkout(alice, books, "1 High Street");

The subsystems still exist, are individually testable, and remain available to callers with genuinely special needs – the facade adds a simple front door, it doesn’t lock the side doors.

Benefits

Seen in the wild

java.nio.file.Files (facade over channels, charsets, attribute views), Spring’s JdbcTemplate (facade over connection/statement/result-set handling), SLF4J’s LoggerFactory.

Implementation

Example test

CheckoutFacadeTest