By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,836 Members | 2,097 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,836 IT Pros & Developers. It's quick & easy.

Mediator design pattern

P: n/a
Hi,

can someone give a real app example of where the Mediator design pattern
could be used ( for instance in a relational database application )?

Thanks,
Josť Carlos Ferreira
Aug 25 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
> can someone give a real app example of where the Mediator design pattern
could be used ( for instance in a relational database application )?


Hello Jose,

That's an odd request. You don't often see the need for a mediator in a db
app. That said, I can come up with one.
Let's say that you have a distributed system. You have two data base
systems (with different data) and two web applications, on different web
servers. Therefore, four participants: db1, db2, wa1, and wa2. All four
fire up a mediator class when they start up. The mediator class handles all
the connection glue, figuring out how each one will talk with another over
the network, and how each will identify the other, and how each will know of
the others' existence.

Assuming we use a mechanism that allows us to set up a config file with
settings about how to communicate, then from within wa1, if I want to speak
with wa2, I could do this:

Mediator M1 = new Mediator();
M1.InitializeFromConfig(this, "wa1"); // read the config and identify
yourself
M1.SendTo("wa2",myObjectMessage);

Does that make sense? The app isn't aware of how the communication is
configured. That is all done by the mediator. I could be dropping files in
a file share, or sending data on a TCP port, or even using .Net Remoting.
The sending app simply sends the message. (if the sending app is expecting
to get a message back, it should probably hook an event from the mediator
object using delegates.

Hope this helps,
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
Aug 26 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.