473,545 Members | 2,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need some help with design patterns.


Hi

I have a domain model and I am looking for the correct design patterns to
use,
The following is my domain model

Server->[Manager->MessagingServi ce->Processors]

the [] is the thread boundaries,the server create a thread
the Thread create the Manager ,the Manager create the MessagingServic e and
the MessagingServic e can create several types of processor, different type
of each message
The messaging service is created using reflection since my server can use
two types:
1. SMTPMessagingSe rvice
2. EXChangeMessagi ngService
my main aim is to be able to exchange the MessagingServic e without compile
the application
The problem which I faces is that both MessagingServic e and Processor object
need a different set of properties depend upon the messaging service which
was installed

currently I am passing an IApplicationCon text down the model
hierarchy ,the AppContext concrete class contains a collection of
properties to be used by the MessagingServic e,
the collection is just a hash table and it is not strong type

when I am installed a new MessagingServic e I add a new set of properties to
the data base
another options that I have is to add to the IApplicationCon text abstract
factories which allow sub component to create
a concrete class and set each concrete class's properties
this method will required me to create a concrete ApplicationCont ext for
each type of
MessagingServic e(I don't mind to do so)
but I don't know how would I notify a sub component that one of its
property was changed?
I can't see how observer can be used here? and if so
would it be a good idea to use the observer pattern for each layer
in such a way that a processor will observe changes in the
MesagingService only,
the MessagingSerice will observe changes in the manager etc.....

even though the properties are being changed in the server layer the
lowest compoent will not directly observe the server

another question that I have in mind is where is the best place in the
domain hierarchy to implement a concrete factory

for example when the MessagingServic e want
to create a Processor it can be used a factory which is implemented by the
Manager
or by Server

using a factory from the manager decouple the processor from higher layers
but the Server layer have the greatest knowledge on how to create a
processor..
Thanks in advance
Jul 21 '05 #1
1 1296
Hello Julia,

It is not clear if your messaging service is sending messages via e-mail, or
receiving them. Since you are using SMTP and not POP3, I assume you are
sending messages. Either way your approach is extraordinarly complex if you
just want to be able to substitute the messaging service.

If I may suggest an implementation that I believe will be easier: create an
entirely new interface -- a Facade. You create some interface classes that
implement the facade but call the different messaging providers. Then, if
the user installs either messaging provider on your system, they simply
provide the fully qualified library name and the class to use, and you
create the Facade instance in your factory. (That or you provide both
facade classes in your library. The user would simply provide a config
setting telling you which one to use).

It sounds like you are about half-way down this track already.

Not sure why you need an observer pattern. (This is normally implemented in
..NET using events.) However, it is frequently unnecessary, especially at
the level that you suggest.

You did not tell us the actual business problem you are trying to solve with
this tangle of classes and threads. Perhaps if you could provide some more
detail about the actual function you are providing, I can be of more help.

--- Nick Malik
Applications Architect

"Julia" <co********@012 .net.il> wrote in message
news:Ot******** ******@TK2MSFTN GP15.phx.gbl...

Hi

I have a domain model and I am looking for the correct design patterns to
use,
The following is my domain model

Server->[Manager->MessagingServi ce->Processors]

the [] is the thread boundaries,the server create a thread
the Thread create the Manager ,the Manager create the MessagingServic e and
the MessagingServic e can create several types of processor, different type
of each message
The messaging service is created using reflection since my server can use
two types:
1. SMTPMessagingSe rvice
2. EXChangeMessagi ngService
my main aim is to be able to exchange the MessagingServic e without compile
the application
The problem which I faces is that both MessagingServic e and Processor object need a different set of properties depend upon the messaging service which
was installed

currently I am passing an IApplicationCon text down the model
hierarchy ,the AppContext concrete class contains a collection of
properties to be used by the MessagingServic e,
the collection is just a hash table and it is not strong type

when I am installed a new MessagingServic e I add a new set of properties to the data base
another options that I have is to add to the IApplicationCon text abstract
factories which allow sub component to create
a concrete class and set each concrete class's properties
this method will required me to create a concrete ApplicationCont ext for each type of
MessagingServic e(I don't mind to do so)
but I don't know how would I notify a sub component that one of its
property was changed?
I can't see how observer can be used here? and if so
would it be a good idea to use the observer pattern for each layer
in such a way that a processor will observe changes in the
MesagingService only,
the MessagingSerice will observe changes in the manager etc.....

even though the properties are being changed in the server layer the
lowest compoent will not directly observe the server

another question that I have in mind is where is the best place in the
domain hierarchy to implement a concrete factory

for example when the MessagingServic e want
to create a Processor it can be used a factory which is implemented by the Manager
or by Server

using a factory from the manager decouple the processor from higher layers
but the Server layer have the greatest knowledge on how to create a
processor..
Thanks in advance

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1624
by: elena | last post by:
Apologies for this off-topic post. I'm a Java/C++ developer who is also studying psychology. I would really appreciate it if you would complete a survey that I'm using for a research project on programmers. It's easy and takes about 5 minutes. I will be presenting the results at the American Psychological
4
2854
by: Tony Ha | last post by:
Hello I am learning Python for in the pass ten months, and have brought a few books about Python. Most of them are good books by its only right, and all of them only teach you how to write Python programs using Python syntax and Python ways, but no one single Python book explicitly teaches you on how to analyst your application, and...
55
3887
by: Alex | last post by:
Hello people, The following is not a troll but a serious request. I found myself in a position where I have to present a Pro/Con list to management and architects in our company with regard to developing new products (specifically - desktop products) in C#/.NET instead of the usual C++/COM that we do. Since I am not an experienced .NET...
1
1117
by: Julia | last post by:
Hi I have a domain model and I am looking for the correct design patterns to use, The following is my domain model Server-> the is the thread boundaries,the server create a thread the Thread create the Manager ,the Manager create the MessagingService and
13
6533
by: John Salerno | last post by:
Here are a few I'm considering: Design Patterns Explained : A New Perspective on Object-Oriented Design (2nd Edition) (Software Patterns Series) by Alan Shalloway Design Patterns C# by Steven John Metsker Design Patterns by Erich Gamma Head First Design Patterns by Elisabeth Freeman
2
2596
by: Carlo Stonebanks | last post by:
I have the infamous GoF Design Patterns boo - it's been sittin gon my shelf for years. I have a huge reading list and find this book a rather dry read and am always putting it off. I have recommendation for "Head First Design Patterns" book, but it's aimed aimed at Java developers. I'd rather have a book that has a "For Dummies" readability...
22
4695
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...
5
2363
by: Ludwig Wittgenstein | last post by:
Other than the Design Patterns book, which book(s) is/are the best to learn object-oriented software design/architecture from ?
7
3094
by: =?Utf-8?B?bWF2cmlja18xMDE=?= | last post by:
Hi, I would like to know more about design patterns and specifically using C#. Can any one recommend a good book? Thanks
0
7499
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...
0
7432
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7689
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7943
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...
1
7456
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...
0
7786
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5359
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...
0
3490
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.