M6 · State, Resources, Two-Axis GrowthSession 12StructuralStill needed as-isOutline

Intent. Split abstraction from implementation so the two can vary independently.

In Kotlin. KMP’s expect/actual is this idea at the language level.

Split abstraction from implementation so both can grow independently. Its diagram matches Strategy’s; the difference is that Strategy swaps an algorithm while Bridge separates two axes of variation. Against Adapter the difference is timing – Bridge is prevention at design time, Adapter is repair after the fact.

Structure

classDiagram
    class Abstraction {
        #impl: Implementor
        +operation()
    }
    class RefinedAbstraction {
        +operation()
        +extraOperation()
    }
    class Implementor {
        <<interface>>
        +operationImpl()
    }
    class ConcreteImplA {
        +operationImpl()
    }
    class ConcreteImplB {
        +operationImpl()
    }
    Abstraction <|-- RefinedAbstraction
    Abstraction o--> Implementor : the bridge
    Implementor <|.. ConcreteImplA
    Implementor <|.. ConcreteImplB

Telling It Apart

Patterns whose structure looks the same but whose intent does not. See the Confusing Pairs reference.

  • Strategy — Encapsulate a family of algorithms as objects and swap them at runtime; the client picks.
  • Adapter — Change an interface so two otherwise incompatible things can work together.