The Mediator pattern defines an object that encapsulates how a set of objects interact. It promotes loose coupling by keeping objects from referring to each other explicitly and lets you vary their interaction independently.

Major Differences:

Mediator centralizes complex communications and control logic between related objects.

It reduces the dependencies between communicating objects. Example: Consider a chat room where users can send messages to each other. The Mediator (ChatRoom) handles the communication between users.

public interface ChatRoomMediator {
    void showMessage(User user, String message);
}

public class ChatRoom implements ChatRoomMediator {
    @Override
    public void showMessage(User user, String message) {
        System.out.println(user.getName() + ": " + message);
    }
}
public class User {
    private String name;
    private ChatRoomMediator chatRoom;

    public User(String name, ChatRoomMediator chatRoom) {
        this.name = name;
        this.chatRoom = chatRoom;
    }

    public String getName() {
        return name;
    }

    public void sendMessage(String message) {
        chatRoom.showMessage(this, message);
    }
}
Summary of Differences:
  1. Facade simplifies the interface of a complex system.
  2. Adapter converts one interface to another to make incompatible interfaces work together.
  3. Mediator centralizes communication between objects to reduce dependencies.

Each pattern addresses different problems and is used in different scenarios to improve code maintainability and flexibility.

This pattern is defined in Design Patterns by Gamma, Helm, Johnson, and Vlissides.