Mediator Method - Python Design Pattern Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report Mediator Method is a Behavioral Design Pattern that allows us to reduce the unordered dependencies between the objects. In a mediator environment, objects take the help of mediator objects to communicate with each other. It reduces coupling by reducing the dependencies between communicating objects. The mediator works as a router between objects and it can have it’s own logic to provide a way of communication. Design Components:Mediator: It defines the interface for communication between colleague objects.Concrete Mediator: It implements the mediator interface and coordinates communication between colleague objects.Colleague: It defines the interface for communication with other colleaguesConcrete Colleague: It implements the colleague interface and communicates with other colleagues through its mediator.Problem Without using Mediator MethodImagine you are going to take admission in one of the elite courses offered by GeeksforGeeks such as DSA, SDE, and STL. Initially, there are very few students who are approaching to join these courses. Initially, the developer can create separate objects and classes for the connection between the students and the courses but as the courses become famous among students it becomes hard for developers to handle such a huge number of sub-classes and their objects. Problem-Mediator-MethodSolution using Mediator MethodNow let us understand how a pro developer will handle such a situation using the Mediator design pattern. We can create a separate mediator class named as Course and a User Class using which we can create different objects of Course class. In the main method, we will create a separate object for each student and inside the User class, we will create the object for Course class which helps in preventing the unordered code. Solution-mediator-method Python3 class Course(object): """Mediator class.""" def displayCourse(self, user, course_name): print("[{}'s course ]: {}".format(user, course_name)) class User(object): '''A class whose instances want to interact with each other.''' def __init__(self, name): self.name = name self.course = Course() def sendCourse(self, course_name): self.course.displayCourse(self, course_name) def __str__(self): return self.name """main method""" if __name__ == "__main__": mayank = User('Mayank') # user object lakshya = User('Lakshya') # user object krishna = User('Krishna') # user object mayank.sendCourse("Data Structures and Algorithms") lakshya.sendCourse("Software Development Engineer") krishna.sendCourse("Standard Template Library") UML DiagramFollowing is the UML Diagram for Mediator Method: Mediator-method-UML-DiagramAdvantagesSingle Responsibility Principle: Extracting the communications between the various components is possible under Mediator Method into a single place which is easier to maintain.Open/Closed Principle: It's easy to introduce new mediators without disturbing the existing client code.Allows Inheritance: We can reuse the individual components of the mediators as it follows the InheritanceFew Sub-Classes: Mediator limits the Sub-Classing as a mediator localizes the behavior that otherwise would be disturbed among the several objects.DisadvantagesCentralization: It completely centralizes the control because the mediator pattern trades complexity of interaction for complexity in the mediator.God Object: A Mediator can be converted into a God Object (an object that knows too much or does too much).Increased Complexity: The structure of the mediator object may become too much complex if we put too much logic inside it.ApplicabilityReduce the number of sub-classes: When you have realized that you have created a lot of unnecessary sub-classes, then it is preferred to use the Mediator method to avoid these unnecessary sub-classes.Air Traffic Controller: Air traffic controller is a great example of a mediator pattern where the airport control room works as a mediator for communication between different flights.Further Read - Mediator Method in Java Comment More infoAdvertise with us Next Article Factory Method - Python Design Patterns C chaudhary_19 Follow Improve Article Tags : Python python-design-pattern Practice Tags : python Similar Reads Python Design Patterns Tutorial Design patterns in Python are communicating objects and classes that are customized to solve a general design problem in a particular context. Software design patterns are general, reusable solutions to common problems that arise during the design and development of software. They represent best pra 7 min read Creational Software Design Patterns in PythonFactory Method - Python Design Patterns Factory Method is a Creational Design Pattern that allows an interface or a class to create an object, but lets subclasses decide which class or object to instantiate. Using the Factory method, we have the best ways to create an object. Here, objects are created without exposing the logic to the cli 4 min read Abstract Factory Method - Python Design Patterns Abstract Factory Method is a Creational Design pattern that allows you to produce the families of related objects without specifying their concrete classes. Using the abstract factory method, we have the easiest ways to produce a similar type of many objects. It provides a way to encapsulate a group 4 min read Builder Method - Python Design Patterns Builder Method is a Creation Design Pattern which aims to "Separate the construction of a complex object from its representation so that the same construction process can create different representations." It allows you to construct complex objects step by step. Here using the same construction code 5 min read Prototype Method Design Pattern in Python The Prototype Method Design Pattern in Python enables the creation of new objects by cloning existing ones, promoting efficient object creation and reducing overhead. This pattern is particularly useful when the cost of creating a new object is high and when an object's initial state or configuratio 6 min read Singleton Method - Python Design Patterns Prerequisite: Singleton Design pattern | IntroductionWhat is Singleton Method in PythonSingleton Method is a type of Creational Design pattern and is one of the simplest design patterns available to us. It is a way to provide one and only one object of a particular type. It involves only one class t 5 min read Structural Software Design Patterns in PythonAdapter Method - Python Design Patterns Adapter method is a Structural Design Pattern which helps us in making the incompatible objects adaptable to each other. The Adapter method is one of the easiest methods to understand because we have a lot of real-life examples that show the analogy with it. The main purpose of this method is to cre 4 min read Bridge Method - Python Design Patterns The bridge method is a Structural Design Pattern that allows us to separate the Implementation Specific Abstractions and Implementation Independent Abstractions from each other and can be developed considering as single entities.The bridge Method is always considered as one of the best methods to or 5 min read Like