| id |
structural/bridge |
| name |
Bridge |
| aliases |
|
| guide_url |
|
| problem |
Let an abstraction and its implementation vary independently, instead of multiplying subclasses across both axes. |
| symptoms |
two hierarchies multiplying |
shapes times renderers |
device times remote |
backend swappable under a stable front |
|
| verdict |
prefer-alternative |
| caveats |
In Python the Bridge collapses into ordinary composition with dependency injection — hold the implementor as an attribute, pass it in. |
The pattern's real lesson survives: name the two axes, give each its own small hierarchy (or set of callables), and connect them with one reference. |
|
| stdlib_sightings |
logging.Logger with logging.Handler |
|
Two independent axes (what to do × how to carry it out) joined by one injected
reference, instead of a subclass per combination. Verdict: prefer an
alternative — composition with dependency injection is the bridge.
uv run python -m patterns.structural.bridge.examples.notification_center.main