M3 · Wrappers: The Four SiblingsSession 6-7StructuralStill needed as-isOutline

Intent. Put one simple interface in front of a complicated subsystem.

In Kotlin. No language feature replaces it. It is a design decision, not a syntax problem.

The odd one of the four wrappers: it preserves no existing interface, it invents a simpler one in front of a subsystem. That is also how you tell it from Adapter – an adapter matches an interface someone else defined, a facade defines its own.

Structure

classDiagram
    class Client
    class Facade {
        +simpleOperation()
    }
    class SubsystemA {
        +opA()
    }
    class SubsystemB {
        +opB()
    }
    class SubsystemC {
        +opC()
    }
    Client --> Facade
    Facade --> SubsystemA
    Facade --> SubsystemB
    Facade --> SubsystemC

Telling It Apart

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

  • Adapter — Change an interface so two otherwise incompatible things can work together.