when the computer systems are becoming larger, communications between classes becomes complex. this complexity becomes simple by using mediator design pattern.
with the mediator pattern, communication between objects is encapsulated with a mediator object. objects no longer directly communicate with each other, instead communicate through the mediator. this reduces the dependencies between communicating objects, thereby lowering the coupling.
Good example of mediator is usage of user groups in Linux operating system. it can have many users, system can have many roles can access the system. when the users are letting access the to the system, if the user is directly mapped to the system role it will be very complex when a change is required. solution is groups, system roles are categorized in to many groups and user are categorized to many user groups. mapping between system groups and user groups will automatically let user to access the system.
Comparison
chain of responsibility, command, mediator and observer design patterns will address how we can control communication between sender and receiver.
chain of responsibility will pass the sender request to a chain of potential receivers.
command specifies a subclass to specify the sender and receiver connection.
mediator has sender and receiver reference each other indirectly.
observer allows receivers to be configured dynamically.
with the mediator pattern, communication between objects is encapsulated with a mediator object. objects no longer directly communicate with each other, instead communicate through the mediator. this reduces the dependencies between communicating objects, thereby lowering the coupling.
Good example of mediator is usage of user groups in Linux operating system. it can have many users, system can have many roles can access the system. when the users are letting access the to the system, if the user is directly mapped to the system role it will be very complex when a change is required. solution is groups, system roles are categorized in to many groups and user are categorized to many user groups. mapping between system groups and user groups will automatically let user to access the system.
Comparison
chain of responsibility, command, mediator and observer design patterns will address how we can control communication between sender and receiver.
chain of responsibility will pass the sender request to a chain of potential receivers.
command specifies a subclass to specify the sender and receiver connection.
mediator has sender and receiver reference each other indirectly.
observer allows receivers to be configured dynamically.
Comments
Post a Comment