Skip to content

Latest commit

 

History

History
 
 

Mediator

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Purpose

This pattern provides an easy to decouple many components working together. It is a good alternative over Observer IF you have a "central intelligence", like a controller (but not in the sense of the MVC).

All components (called Colleague) are only coupled to the MediatorInterface and it is a good thing because in OOP, one good friend is better than many. This is the key-feature of this pattern.

UML Diagram

Alt Mediator UML Diagram

Code

You can also find these code on GitHub

MediatorInterface.php

MediatorInterface.php

Mediator.php

Mediator.php

Colleague.php

Colleague.php

Subsystem/Client.php

Subsystem/Client.php

Subsystem/Database.php

Subsystem/Database.php

Subsystem/Server.php

Subsystem/Server.php

Test

Tests/MediatorTest.php

Tests/MediatorTest.php