From the course: Java Design Patterns: Behavioral Part 1

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Understanding the Mediator pattern

Understanding the Mediator pattern - Java Tutorial

From the course: Java Design Patterns: Behavioral Part 1

Start my 1-month free trial

Understanding the Mediator pattern

- [Instructor] The actual definition of a mediator is someone who tries to make people in conflict, come to an agreement. They act as a neutral party who sits in between all of the others so that they don't speak to each other directly. In Java, the mediator pattern is a way for objects to communicate so that they are loosely coupled. As a real life example, imagine a restaurant, the customer is at their table and they need to communicate what they want to eat. The chefs are in the kitchen and they need to know what to cook. And then the meal needs to be brought out. The owner of the restaurant needs to make a profit to run the restaurant. So money needs to be collected from the customers. Imagine how it would work if there was no waiter or waitress. The customer would have to go to the kitchen to tell the chefs what they want. Then the chefs would have to bring out the food and at the end of the meal, the owner…

Contents