Bridge pattern
medium 50 minThe Bridge pattern splits one exploding hierarchy into two that are joined by a reference, so that what is wanted and how a platform does it can grow apart.
Watch lesson4:19
Where it shows up
The same pattern appears across everyday software.
Go: log/slog
A Logger offers Info, Error and With to callers, and passes records to a Handler that formats and writes them. Anyone can write a Handler, and the Logger does not change.
Qt Platform Abstraction
Qt's main platform layer. Classes with the prefix QPlatform are used to implement higher level classes, and a plugin provides them for one window system.
JDBC
Every driver implements java.sql.Driver, and the framework allows for multiple database drivers. DriverManager looks up drivers through the service-provider mechanism.
SLF4J
Callers use one logging API. A provider for logback, reload4j or java.util.logging is linked in when the program is deployed. It calls itself a facade; its two sides vary like a bridge.
Linux VFS
The virtual file system gives programs one interface and is an abstraction inside the kernel that lets different file systems coexist. open and read are the same for all of them.
C++ pimpl
cppreference describes it as a technique for library interfaces with a stable ABI and fewer compile-time dependencies. Qt's d-pointers are the same idea.
SQLAlchemy dialects
The engine and the expression language sit on one side, a dialect for PostgreSQL, MySQL and others on the other. A dialect knows the types, the syntax and the driver.
Flutter embedders
A platform-specific embedder provides the entry point and coordinates with the operating system for rendering surfaces, accessibility and input. The framework above is the same on each platform.
Python logging
Loggers expose the interface that application code uses, handlers send the records to a destination. Any logger can have any handlers.