15

Adapter, Facade, Bridge: composing a shipping subsystem

Wrapping a foreign carrier client, presenting one surface over a subsystem, and splitting an abstraction from its implementation.

Demo 15Source on GitHub ↗

Three structural patterns that compose existing parts. Adapter wraps a foreign courier SDK so it satisfies the app’s CarrierGateway interface. Facade presents one small surface over a four-part subsystem (rating, labeling, customs, tracking). Bridge lets notification kinds and delivery channels vary independently, so a new kind or a new channel is one new class, not one per combination.

The JUnit 5 tests verify the adapter’s unit translation per zone (Mockito mocks the foreign client), the facade’s subsystem call order (InOrder) plus end-to-end domestic vs international behavior, and the bridge’s kind-by-channel matrix.

Build, run, observe

cd examples/15-adapter-facade-bridge
mvn -q test
./demo.sh

The module also runs from the aggregator root with mvn -q -f examples/pom.xml test.