I know that Adapter is a structural pattern and Mediator is a behavioral one. But as far I understood, what both of them are doing, is connecting two (or more) other classes which are potentially incompatible (not so maintainable) for direct communication.
Can some one give a close comparison between these two and point out the exact difference?
These are the links for Adapter and Mediator explanations in TutorialsPoint.
And these are sourcemaking explanations. Adapter, Mediator.
JB Nizet already wrote a good answer. I just want to explain the differences in simpler words:
Mediator should be used when you don't know how to communicate with other objects or you aren't allowed to
Adapter should be used when you know exactly how to communicate with objects, but these objects might not support some communication methods or differ
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With