Return to site

DESIGN PATTERN: Mediator

· pattern

The _____ Pattern is a design pattern that centralizes communication between objects through a mediator, reducing direct dependencies and promoting loose coupling.

It simplifies complex interactions and enhances maintainability.

* Visitor

* Iterator

* Mediator

* Interpreter

#design #pattern #mediator

Answer: Mediator

The Mediator Pattern is a behavioral design pattern in software development that promotes loose coupling between objects by centralizing their interactions through a mediator object.

It helps manage complex communication and coordination between objects without them needing to be aware of each other.

broken image

Mediator:

The Mediator is an interface or class that defines the communication contract between different objects.

It typically includes methods for objects to register, send, and receive messages.

Concrete Mediator:

The Concrete Mediator class implements the Mediator interface and coordinates the interactions between participating objects.

It maintains references to the objects it manages.

Colleague:

Colleague objects are the participants in the communication.

They implement the Colleague interface and are aware of the Mediator.

Colleagues communicate with each other indirectly through the Mediator, rather than directly with each other.

The Mediator Pattern is valuable in scenarios where multiple objects need to collaborate but should remain loosely coupled.

It simplifies the communication between objects by reducing dependencies and promotes modularity, making it easier to extend and maintain the system.

It is often used in user interface frameworks and complex event-driven systems.