Mediator Pattern Code Review

Use the Mediator Pattern

Code Review

Code Walkthrough

The Program class creates the Mediator object and various Colleague objects.

class Program { static void Main(string[] args) { Mediator m = new Mediator();
Colleague head1 = new Colleague(m, "John"); ColleagueB branch1 = new ColleagueB(m, "David"); Colleague head2 = new Colleague(m, "Lucy");
head1.Send("Meeting on Tuesday, please all ack"); branch1.Send("Ack"); m.Block(branch1.Receive); head1.Send("Still awaiting some Acks"); head2.Send("Ack"); m.Unblock(branch1.Receive); head1.Send("Thanks all");
Console.Read(); } }

Messages are then exchanged between the Colleague objects, through the Mediator object.