Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Mediator pattern
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Overview== The mediator<ref name="GoF">{{cite book|author=Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides|title=Design Patterns: Elements of Reusable Object-Oriented Software|year=1994|publisher=Addison Wesley|isbn=0-201-63361-2|pages=[https://archive.org/details/designpatternsel00gamm/page/273 273ff]|url-access=registration|url=https://archive.org/details/designpatternsel00gamm/page/273}}</ref> design pattern is one of the twenty-three well-known [[Design Patterns|design patterns]] that describe how to solve recurring design problems to design flexible and reusable object-oriented software, that is, objects that are easier to implement, change, test, and reuse. ===Problems that the mediator design pattern can solve=== Source:<ref>{{cite web |title=The Mediator design pattern - Problem, Solution, and Applicability |url=http://w3sdesign.com/?gr=b05&ugr=proble |first=Günther |last=Franke |website=w3sDesign |access-date=2017-08-12}}</ref> * Tight coupling between a set of interacting objects should be avoided. * It should be possible to change the interaction between a set of objects independently. Defining a set of interacting objects by accessing and updating each other directly is inflexible because it tightly couples the objects to each other and makes it impossible to change the interaction independently from (without having to change) the objects. And it stops the objects from being reusable and makes them hard to test. ''Tightly coupled objects'' are hard to implement, change, test, and reuse because they refer to and know about many different objects. ===Solutions described by the mediator design pattern === * Define a separate (mediator) object that encapsulates the interaction between a set of objects. * Objects delegate their interaction to a mediator object instead of interacting with each other directly. The objects interact with each other indirectly through a mediator object that controls and coordinates the interaction. This makes the objects ''loosely coupled''. They only refer to and know about their mediator object and have no explicit knowledge of each other. See also the UML class and sequence diagram below.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)