Mediator

Reduce coupling between communicating objects

Overview

Mediator reduces chaotic dependencies between objects. The pattern restricts direct communications between the objects and forces them to collaborate only via a mediator object.

Code Example

java
1public interface ChatMediator { void sendMessage(String msg, User user); void addUser(User user); }
2// User objects talk to ChatMediator instead of directly to each other

AI Tutor

Ask about the topic

Sign in Required

Please sign in to use the AI tutor

Sign In
Mediator - Behavioral Patterns | LLD | Revise Algo