From a3648c449e29eaa98f1dac5dfc27e7f56b5d3a86 Mon Sep 17 00:00:00 2001 From: Trismegiste Date: Sun, 12 May 2013 14:32:16 +0200 Subject: [PATCH] adding comments --- Mediator/Mediator.php | 5 +++-- README.markdown | 2 +- Tests/Mediator/MediatorTest.php | 3 +++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Mediator/Mediator.php b/Mediator/Mediator.php index d6edb8c..98b34a1 100644 --- a/Mediator/Mediator.php +++ b/Mediator/Mediator.php @@ -15,8 +15,9 @@ use DesignPatterns\Mediator\Subsystem; * 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 objects (called Colleague) are coupled only to the MediatorInterface and - * it is a good thing because in OOP, one good friend is better than many unreliable. + * 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. * * In this example, I have made a "Hello World" with the Mediator Pattern, have fun (^_^) */ diff --git a/README.markdown b/README.markdown index 3742786..168fc4a 100644 --- a/README.markdown +++ b/README.markdown @@ -23,4 +23,4 @@ Changes I've made : * Fixing the Adapter Pattern because it was buggy and incomplete (+ Tests) * Adding Template Method Pattern (+ Tests) * Adding Builder Pattern (+ Tests) -* \ No newline at end of file +* Adding Mediator Pattern (+ Tests) \ No newline at end of file diff --git a/Tests/Mediator/MediatorTest.php b/Tests/Mediator/MediatorTest.php index b673985..f4f689d 100644 --- a/Tests/Mediator/MediatorTest.php +++ b/Tests/Mediator/MediatorTest.php @@ -30,7 +30,10 @@ class MediatorTest extends \PHPUnit_Framework_TestCase { // testing if Hello World is output : $this->expectOutputString('Hello World'); + // as you see, the 3 components Client, Server and Database are totally decoupled $this->client->request(); + // Anyway, it remains complexity in the Mediator that's why the pattern + // Observer is preferable in mnay situations. } } \ No newline at end of file