473,803 Members | 3,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1833
> 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.InitializeFr omConfig(this, "wa1"); // read the config and identify
yourself
M1.SendTo("wa2" ,myObjectMessag e);

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
3601
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 solution. I am implementing the Mediator pattern to create an event-driven app. The Collaborators (which watch for various events and which all have a reference to the Mediator object) will call handleEvent(Event e) on the Mediator object when...
0
992
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
278
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
3042
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 itself. The called class has special functions for each class that can call it. With the visitor pattern, the calling class can have new operations added without being changed itself.
1
2714
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, tried to simplify my test program structure a bit. testMediator.php has only one html tag in it - a <BR>. This is in my new writeln() function, which adds '<'.'BR'.'>' to each line and
22
4750
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. Also describes implementation via ChangeManager (Mediator + Singleton) 2) Pattern hatching by John Vlissides Describes Observer's implementation via Visitor Design Pattern. 3) Design Patterns Explained by Alan Shalloway and James Trott
1
1737
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 had no connection or reference to the object that triggered it. It goes something like this: (not syntactically correct..it's just for the idea)
1
4163
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 had no connection or reference to the object that triggered it. It goes something like this: (not syntactically correct..it's just for the idea)
9
2403
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 delegates. The first way is an adaptation from C++ for Dummies by Jeff Cogswell. But obviously it uses references not pointers. The second way (I'll post this later, as I haven't yet done it) will be adapted from the book C#3.0 Design Patterns by...
0
9703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10317
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10295
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7604
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5633
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2972
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.