473,386 Members | 1,693 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.

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

Similar topics

7
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...
4
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...
55
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...
1
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...
13
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...
2
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...
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....
5
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
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
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.