What is the difference between interpreter and mediator design pattern?

456 Views Asked by At

I am reading design pattern and going through the concept of all that.

Facing some issue while reading the concept of the mediator and interpreter pattern...Can any body please help me to get clear about this

By example and explanation which I got from internet it is stating that..

Interpreter A way to include language elements in a program

Mediator Defines simplified communication between classes

But when we think about the Interpreter it also looks doing same thing as mediator...as in interpreter the middle interface is required that can convert the language elements(seen in example of Roman to normal number conversion from interpreter example) also mediator concept provides middle interface that can communicate with other interfaces.

Can anyone give generic example that can clarify the clear difference between Mediator and Interpreter pattern.

Please give example in c++ as I am not aware of java concepts.

1

There are 1 best solutions below

0
On BEST ANSWER

Interpreter pattern is used to interpreter a (domain) language defined with grammatical rules. Mediator is used when it is hard to achieve synchronization among the lot of objects, then communication goes via mediator.

Hope that this helps.