2015-08-13 23:54:40 +02:00
|
|
|
---
|
|
|
|
layout: pattern
|
|
|
|
title: Mediator
|
|
|
|
folder: mediator
|
2015-08-15 18:03:05 +02:00
|
|
|
permalink: /patterns/mediator/
|
2015-08-16 17:07:36 +05:30
|
|
|
categories: behavioral
|
2015-08-13 23:54:40 +02:00
|
|
|
tags: pattern_tag
|
|
|
|
---
|
|
|
|
|
|
|
|
**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, and it lets you vary their interaction independently.
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
**Applicability:** Use the Mediator pattern when
|
|
|
|
|
|
|
|
* a set of objects communicate in well-defined but complex ways. The resulting interdependencies are unstructured and difficult to understand
|
|
|
|
* reusing an object is difficult because it refers to and communicates with many other objects
|
2015-08-15 18:03:05 +02:00
|
|
|
* a behavior that's distributed between several classes should be customizable without a lot of subclassing
|