Need some help with design patterns.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Julia

    #1

    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


  • Nick Malik

    #2
    Re: Need some help with design patterns.

    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" <codewizard@012 .net.il> wrote in message
    news:Ot8hdjLxEH A.3808@TK2MSFTN GP15.phx.gbl...[color=blue]
    >
    > 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[/color]
    object[color=blue]
    > 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[/color]
    to[color=blue]
    > 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[/color]
    for[color=blue]
    > 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[/color]
    the[color=blue]
    > 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
    >
    >[/color]


    Comment

    Working...