Pattern · Core

Mediator

Stop components from referencing each other directly; route all their interaction through ONE mediator — turning a tangled web (N×N) into a clean hub (N).

Asked atAmazonSlackGoogle
step 1 / 7
1/2Everyone wired to everyone
Button
Checkbox
TextField
Label
Everyone wired to everyone
1class Button { Checkbox c; TextField t; Label l; ... }
2class Checkbox { TextField t; Label l; ... }
3class TextField { Label l; ... } // every widget knows the rest
State
linksa tangled mesh

Four widgets in a dialog — Button, Checkbox, TextField, Label — each holding direct references to the others. Every line is one widget reaching into another.