79712792

Date: 2025-07-24 04:25:07
Score: 0.5
Natty:
Report link

I think the main difference is Observer is fine for one-way communication but poor at two-way; Mediator is good at two-way communication, . Let's say you have a chat application, and you choose to implement it with an Observer pattern. Each client needs Publish, and also each client needs to subscribe to every other client.

For two clients, that's both objects publishing and each object subscribing to one other object. For three clients, all three are publishing and each client subscribing to two, totaling six subscriptions. This increases by n!.

If instead you implement with the Mediator pattern, because you only need one connection per object to the Mediator, it increases linearly.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: Naughton