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

Need some help with design patterns.

P: n/a

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->MessagingService->Processors]

the [] is the thread boundaries,the server create a thread
the Thread create the Manager ,the Manager create the MessagingService and
the MessagingService 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. SMTPMessagingService
2. EXChangeMessagingService
my main aim is to be able to exchange the MessagingService without compile
the application
The problem which I faces is that both MessagingService and Processor object
need a different set of properties depend upon the messaging service which
was installed

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

when I am installed a new MessagingService I add a new set of properties to
the data base
another options that I have is to add to the IApplicationContext 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 ApplicationContext for
each type of
MessagingService(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 MessagingService 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
Share this Question
Share on Google+
1 Reply


P: n/a
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**************@TK2MSFTNGP15.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->MessagingService->Processors]

the [] is the thread boundaries,the server create a thread
the Thread create the Manager ,the Manager create the MessagingService and
the MessagingService 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. SMTPMessagingService
2. EXChangeMessagingService
my main aim is to be able to exchange the MessagingService without compile
the application
The problem which I faces is that both MessagingService and Processor object need a different set of properties depend upon the messaging service which
was installed

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

when I am installed a new MessagingService I add a new set of properties to the data base
another options that I have is to add to the IApplicationContext 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 ApplicationContext for each type of
MessagingService(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 MessagingService 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 discussion thread is closed

Replies have been disabled for this discussion.