Published Jun 3, 2016

Command, Repository and Mediator Design Patterns

    Delve into the intricacies of Command, Repository, and Mediator design patterns, as Coding Blocks hosts discuss their practical applications in software design, the importance of loose coupling, and the benefits of diversifying programming skills and effective unit testing.
    Episode Highlights
    Coding Blocks logo

    Popular Clips

    Episode Highlights

    • Pattern Examples

      The mediator pattern is a design approach that encapsulates how a set of objects interact, promoting loose coupling by preventing direct references between them. Michael Outlaw explains that this pattern allows an 11th object, the mediator, to manage communication among ten other objects, ensuring they operate independently while still interacting effectively 1. A practical example is air traffic control, where planes communicate through a central control rather than directly with each other 2.

      All of the planes don't know. They don't talk to each other and they don't even know how to talk to each other, but they go through their traffic control and they communicate with, with that group.

      --- Michael Outlaw

      This pattern is also applicable in web development, where a mediator can manage interactions between web components without them being aware of each other 3.

         

      Pattern Comparison

      The mediator and observer patterns both facilitate communication between objects, but they do so in distinct ways. Michael Outlaw notes that while the observer pattern notifies all dependent objects of changes, the mediator pattern actively manages interactions by deciding what actions to take based on the changes 4. This distinction is exemplified by the air traffic control analogy, where the mediator (control tower) directs planes based on specific needs, unlike the observer pattern, which would merely broadcast changes 5.

      The mediator knows how to do things to the other ones. It's not notifying the other objects. It can go do things to those objects.

      --- Alan Underwood

      This nuanced difference highlights the mediator's role in decision-making, contrasting with the observer's role in event notification 6.

    Related Episodes