The Mediator pattern is a behavioral GoF design pattern by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides that defines an object which encapsulates how a set of objects interact. The objects no longer refer to each other explicitly but communicate through the mediator, which promotes loose coupling, makes each object easier to reuse and centralizes complex coordination, for example between form, list and filter components in a UI.

GoF-Mediator Pattern

Details
Full Name

GoF Mediator Pattern (Behavioral)

Intent:

Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly.

When to Use:

  • When a set of objects communicate in well-defined but complex ways

  • When reusing an object is difficult because it refers to and communicates with many other objects

  • When behavior distributed between several classes should be customizable without excessive subclassing

Prompt Example:

"Führe einen Mediator nach GoF ein, der die Kommunikation zwischen den UI-Komponenten (Formular, Liste, Filter) zentral koordiniert und die direkte Kopplung beseitigt."