473,386 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Mediator design pattern

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
1 1811
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: cppaddict | last post by:
I have a design question which I am posting here because the implementation will be in C++ and I think there may be C++ specific language constructs (eg, friends) that might be relevant to the...
0
by: Horst Klein | last post by:
Hi I'm searching a sample how to use a ChangeManager (Based on the Mediator Pattern) How can help me? Best regards Horst
1
by: Coder-X | last post by:
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
12
by: FluffyCat | last post by:
New on November 28, 2005 for www.FluffyCat.com PHP 5 Design Pattern Examples - the Visitor Pattern. In the Visitor pattern, one class calls a function in another class and passes an instance of...
1
by: FluffyCat | last post by:
I finally pieced together what I think is a good example of the Mediator Pattern in PHP 5. See what you think. http://www.fluffycat.com/PHP-Design-Patterns/Mediator/ I have, per request,...
22
by: Krivenok Dmitry | last post by:
Hello All! I am trying to implement my own Design Patterns Library. I have read the following documentation about Observer Pattern: 1) Design Patterns by GoF Classic description of Observer....
1
by: halekio | last post by:
Hi all, Please bear with me as I've only started programming in C# 2 weeks ago and this is my first contact with OOP. I ran into a situation where I needed to catch an event in an object that...
1
by: halekio | last post by:
Hi all, Please bear with me as I've only started programming in C# 2 weeks ago and this is my first contact with OOP. I ran into a situation where I needed to catch an event in an object that...
9
by: raylopez99 | last post by:
Here are two different ways of achieving a mediator pattern: the first, using circular references (for lack of a better way to describe it), but not using delegates, with the second using...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.