What the pattern is trying to achieve
Wrap a business workflow behind a coarse-grained service boundary suited to application or remote clients.
Session Facade exposes coarse-grained business operations so clients do not need to coordinate many fine-grained calls across a boundary.
Checkout, refund, and shipment flows usually involve several services. A coarse-grained application boundary keeps clients from reassembling that workflow themselves.
Wrap a business workflow behind a coarse-grained service boundary suited to application or remote clients.
Clients make too many small calls across a boundary and end up understanding workflow details they should not own.
Provide a higher-level facade that executes the use case and returns a meaningful outcome.
This remains one of the most important enterprise patterns because many modern application services are effectively Session Facades with better DI and tooling.
package org.javaomnibus.ecommerce.application;
public final class CheckoutSessionFacade {
private final InventoryService inventoryService;
private final PaymentService paymentService;
private final ShipmentService shipmentService;
public CheckoutSessionFacade(
InventoryService inventoryService,
PaymentService paymentService,
ShipmentService shipmentService
) {
this.inventoryService = inventoryService;
this.paymentService = paymentService;
this.shipmentService = shipmentService;
}
public CheckoutReceipt checkout(CheckoutCommand command) {
Reservation reservation = inventoryService.reserve(command.orderId());
PaymentReceipt payment = paymentService.capture(command.orderId(), command.amount());
ShipmentPlan shipment = shipmentService.plan(command.orderId(), command.address());
return new CheckoutReceipt(reservation, payment, shipment);
}
}
Session Facade resembles a modern application service. Business Delegate shields callers from access complexity, while Session Facade defines the coarse-grained business use case boundary itself.