Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Design and Architecture
  4. It's mediators all the way down.

It's mediators all the way down.

Scheduled Pinned Locked Moved Design and Architecture
oopdesignalgorithmsregexarchitecture
3 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Leslie Sanford
    wrote on last edited by
    #1

    I've been re-reading Arthur J. Riel's classic "Object-Oriented Design Heuristics." One thing that I've found striking on this re-reading is how much Riel emphasizes the use of the mediator design pattern (though he doesn't refer to it as such). Specifically, it's heuristic 4.14: "Objects which share lexical scope, should not have uses relationships between them." What this means, basically, is that objects that exist at the same level of abstraction shouldn't be communicating with each other. Rather, they should be communicating with an object at a higher level of abstract which in turn takes the appropriate action and communicates any necessary info to the other objects at the lower level of abstraction, in other words, the mediator pattern. (as an aside this heuristic conflicts somewhat with heuristic 4.13. Riel addresses this by suggesting the use of abstract classes, i.e. interfaces, as a means through which children communicate with their parents) There are at least a couple of reasons for this heuristic. One, it promotes decoupling and reuse. If the objects at the same level of abstraction don't know about each other, they're more likely to be reuseable. Two, it lowers complexity. Instead of a many-to-many relationship between objects, you have a one-to-many, i.e. the mediator has a one-to-many relationship with its child objects. One-to-many relationships are easier to reason about and understand. Following this heuristic, you can wind up with a layered approach in which each layer is made up of mediators. The child objects are in turn mediators to their child objects, and so on. I like this idea in that it seems to strike a balance between a hyper object oriented approach in which objects are tangled together in a complex many-to-many web of connections and a strictly procedural approach in which nothing is connected. I'd never thought of mediator in this light before.

    P J 2 Replies Last reply
    0
    • L Leslie Sanford

      I've been re-reading Arthur J. Riel's classic "Object-Oriented Design Heuristics." One thing that I've found striking on this re-reading is how much Riel emphasizes the use of the mediator design pattern (though he doesn't refer to it as such). Specifically, it's heuristic 4.14: "Objects which share lexical scope, should not have uses relationships between them." What this means, basically, is that objects that exist at the same level of abstraction shouldn't be communicating with each other. Rather, they should be communicating with an object at a higher level of abstract which in turn takes the appropriate action and communicates any necessary info to the other objects at the lower level of abstraction, in other words, the mediator pattern. (as an aside this heuristic conflicts somewhat with heuristic 4.13. Riel addresses this by suggesting the use of abstract classes, i.e. interfaces, as a means through which children communicate with their parents) There are at least a couple of reasons for this heuristic. One, it promotes decoupling and reuse. If the objects at the same level of abstraction don't know about each other, they're more likely to be reuseable. Two, it lowers complexity. Instead of a many-to-many relationship between objects, you have a one-to-many, i.e. the mediator has a one-to-many relationship with its child objects. One-to-many relationships are easier to reason about and understand. Following this heuristic, you can wind up with a layered approach in which each layer is made up of mediators. The child objects are in turn mediators to their child objects, and so on. I like this idea in that it seems to strike a balance between a hyper object oriented approach in which objects are tangled together in a complex many-to-many web of connections and a strictly procedural approach in which nothing is connected. I'd never thought of mediator in this light before.

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      The use of the Mediator is a common technique in MVVM to provide cross-communication between ViewModels without requiring complex communication infrastructure. It's a great way to keep them decoupled.

      Forgive your enemies - it messes with their heads

      My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

      1 Reply Last reply
      0
      • L Leslie Sanford

        I've been re-reading Arthur J. Riel's classic "Object-Oriented Design Heuristics." One thing that I've found striking on this re-reading is how much Riel emphasizes the use of the mediator design pattern (though he doesn't refer to it as such). Specifically, it's heuristic 4.14: "Objects which share lexical scope, should not have uses relationships between them." What this means, basically, is that objects that exist at the same level of abstraction shouldn't be communicating with each other. Rather, they should be communicating with an object at a higher level of abstract which in turn takes the appropriate action and communicates any necessary info to the other objects at the lower level of abstraction, in other words, the mediator pattern. (as an aside this heuristic conflicts somewhat with heuristic 4.13. Riel addresses this by suggesting the use of abstract classes, i.e. interfaces, as a means through which children communicate with their parents) There are at least a couple of reasons for this heuristic. One, it promotes decoupling and reuse. If the objects at the same level of abstraction don't know about each other, they're more likely to be reuseable. Two, it lowers complexity. Instead of a many-to-many relationship between objects, you have a one-to-many, i.e. the mediator has a one-to-many relationship with its child objects. One-to-many relationships are easier to reason about and understand. Following this heuristic, you can wind up with a layered approach in which each layer is made up of mediators. The child objects are in turn mediators to their child objects, and so on. I like this idea in that it seems to strike a balance between a hyper object oriented approach in which objects are tangled together in a complex many-to-many web of connections and a strictly procedural approach in which nothing is connected. I'd never thought of mediator in this light before.

        J Offline
        J Offline
        jschell
        wrote on last edited by
        #3

        Mediator use isn't strictly mandated to achieve the same thing. Some alternatives - Pass an interface. - Refactor discoved common code into its own grouping.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups