Chapter 12. Mediator Pattern

Complex intertwined, or "spaghetti," code just doesn't get the respect it deserves. The extensive coupling, managed interdependencies, and monolithic code streams are a testament to the beauty, hard work, and sheer brilliance of the programmer. I can't believe "spaghetti" code gets such a bad rap. Programmers, from novice to experienced, will have picked up on my sarcasm by now. However, very often, this is the mindset that one has to acquire in order to not go crazy when working with a software application. Additional features, scope creep, and too many cooks in the kitchen can lead to this interwoven repository of code. The term object oriented seems to be lost. Chances are that this cluster of inseparable code was once a very sleek, fast, and modular system. But similar objects within the system started finding out too much about each other, applying updates to each other, and generally being too tightly coupled. But there is hope. When many similar objects need to accept changes, without being tightly coupled, the Mediator Design Pattern is there to lend a hand.

Name: Mediator

The Mediator Design Pattern is used to develop an object that communicates or mediates changes to a collection of similar objects without them interacting with each other directly.

Get Professional PHP Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.