Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
id behavioral/mediator
name Mediator
aliases
coordinator
hub
guide_url
problem Stop a web of objects from referencing each other by routing their interactions through one coordinator.
symptoms
widgets updating each other
N-squared object references
form fields with interdependent rules
components need decoupling
verdict use-with-care
caveats
The mediator earns its keep by deleting pairwise references; if it grows into a god object that knows everything, you traded a web for a blob.
For pipeline-shaped decoupling, a queue between producers and consumers is the simpler mediator.
stdlib_sightings
queue.Queue
asyncio.Queue

Mediator

Route component interactions through one coordinator that owns every rule. Verdict: use with care — excellent for genuinely tangled rules; watch for god-object drift.

Where What
pattern/ The importable code: Field (dumb value holder) + Form (the mediator base owning recheck)
docs/ Fundamentals · Implementation guide · External examples
examples/checkout_form/ Mini-project: cascading checkout rules built on pattern/
tests/ Behavioral tests for the pattern and the mini-project
uv run python -m patterns.behavioral.mediator.examples.checkout_form.main