Mid From PDF GoF Patterns Gang of Four Patterns

Concrete Mediator (ChatMediator):?

Short answer: The ChatMediator class is the concrete mediator that implements IChatMediator. It manages a list of users and is responsible for broadcasting messages to all registered users, except the one who sent the message. The mediator decouples the user objects from each other, so they don't need to know about each other's existence. public class ChatMediator : IChatMediator

Example code

{
private readonly List<User> _users = new List<User>();
public void RegisterUser(User user) => _users.Add(user);
public void SendMessage(string message, User user)
{
foreach (var u in _users)
{ // Message should not be sent to the user who sent it if (u != user)
{ u.Receive(message); }
}
}
}

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details