Mediator design pattern is a pattern used to communicate between related object using mediator , the communication happens in such way that either party is not aware of the underlying communication mechanism.
So as a classic example is our BSE and NSE stock exchange , the exchange facilitates with different stock offerings and they don't hold any stocks with them , it is broker which offers to sale or buy to NSE or BSE and which facilitates the buying or selling of the share .
So here BSE and NSE are the mediator which provides hooks for different brokers zerodha, sharekhan... to register and perform the trade , one broker offers to sale certain shares to and other broker buys the same , and this task is performed by the mediator silently without bothering each other.
Please follow the UML diagram for the same.
Here we have Colleague object which is nothing but the abstract broker and then we have different implementation of broker's like sharekhan , zerodha which are concretecolleague and we have the Mediator which is(NSE/BSE) and so mediator keeps record of all the brokers and perform the buying and selling of shares on the behalf of different registered brokers.
So as a classic example is our BSE and NSE stock exchange , the exchange facilitates with different stock offerings and they don't hold any stocks with them , it is broker which offers to sale or buy to NSE or BSE and which facilitates the buying or selling of the share .
So here BSE and NSE are the mediator which provides hooks for different brokers zerodha, sharekhan... to register and perform the trade , one broker offers to sale certain shares to and other broker buys the same , and this task is performed by the mediator silently without bothering each other.
Please follow the UML diagram for the same.
Here we have Colleague object which is nothing but the abstract broker and then we have different implementation of broker's like sharekhan , zerodha which are concretecolleague and we have the Mediator which is(NSE/BSE) and so mediator keeps record of all the brokers and perform the buying and selling of shares on the behalf of different registered brokers.
Comments
Post a Comment