Welcome to my Mediator Design Pattern Tutorial! The Mediator design pattern is used to handle communication between related objects (Colleagues). All communication is handled by a Mediator Object and the Colleagues donโt need to know anything about each other to work together.
The Gang of Four description:ย Allows loose coupling by encapsulating the way disparate sets of objects interact and communicate with each other.ย Allows for the actions of each object set to vary independently of one another.
If you like videos like this, it helps to tell Google [googleplusone]
Share if you know anyone that would like this [nttfblike]
Code from the Video
STOCKOFFER.JAVA
COLLEAGUE.JAVA
GORMANSLACKS.JAVA
JTPOORMAN.JAVA
MEDIATOR.JAVA
STOCKMEDIATOR.JAVA
TESTSTOCKMEDIATOR.JAVA
small correction in buyOffer() function.
System.out.println(shares + ” shares of ” + stock +
” bought by colleague code ” + collCode);
collCode instead of offer.getCollCode()
I think you can use both of them ๐
Yes Atul u r right .. because a buyer cannot buy the shares he is selling .. buy share offer operation is intiated by Colleage 2 i.e. JP Morgan!!
@Derek – Good practiccal example great tutorial!!
Thank you ๐
Hi Derek!
I want to thank you very much for the effort you make preparing these tutorials. There are very few people on the web that are both willing to teach and along with that know what they’re doing. These videos are great supplement to the GOF’s book.
BTW, this is the first video that was really hard to grasp. The reason was the financial theme you’ve chosen to deal with. It took me 5 minutes to understand the pattern, but 20 minutes to get into broker-shares-sale-buy relationship ๐ I’m definitely dumb in finance..
Regards,
Mike
Hi Mike,
Sorry about the weird example. I have been doing my best to avoid weird tutorials like that in the future. I’m happy you were able to understand it though in the end ๐