Mediator Pattern

noun

say it: “MEE-dee-ay-ter PAT-urn” /ˈmidiˌeɪtər ˈpætərn/

A design pattern in which parts talk only through one object in the middle, which holds the rules about who reacts to what.

What is the Mediator pattern?

The Mediator pattern puts one hub in the middle of parts that react to each other. Each part tells the hub what happened ("front door unlocked"), and only the hub knows who should react (the alarm turns off, the hallway light comes on). The parts no longer hold each other, and a new rule goes in one place.

In a sentence

  • “With the hub as a mediator, the front door only said "unlocked", and the hub decided that the alarm and the lights should react.”

Level: Journeyman · More OOP terms at this level

Updated