Mitchel's Forums

Subject: Design Pattern question...
Prev Next
You are not authorized to post a reply.

AuthorMessages
mikeUser is Offline
New Poster
New Poster
Posts:13

04/19/2008 4:24 AM  

My client application will have a set of varying business functions. These functions will be fullfiled via various 3rd party services (i.e. web services, http post/get, remote data access or socket to socket feeds)...in other words, the protocol for getting to those services to fulfill a business request may be different.  

What i intend to do is to define the functions in an interface so that the client code can be implemented against this interface independent of the business or data tiers which will actually execute the action; let's call this interface IClientServices .

Now the dilema i am facing is in by business/data tier which will be reaching out to the services to perform the tasks, how to i get IClientServices to work against the various services. One idea was to build a wrapper for each service.  The concrete implementation (call it ConcreteClientServices) of  IClientServices can then use composition and delegation to interact with the various services (the wrappers would be members ConcreteClientServices).  The issue here though is that if we move from one 3rd part service,  we obviously would have to create a new wrapper for this new service...that's fine.  However, what is troubling is having to modify ConcreteClientServices each time we change to a new service provider, since i am using delegation within the concrete implementation. With this method, i still have a dependency on 3rd party services sort of...it's not a clean separation. What is the best way to solve this problem? 

Also, how do you handle a situation where a single set of related business functions require interaction with two or more different 3rd party services?  Would it be best to build one adapter that uses IClientServices, and through composition and delegation, does the dirty work of figuring out which methods should be mapped to the different services (rather than creating separate adapter for each service as described in my above paragraph).  Is the pattern here
considered Adapter or Provider? 

thanks,
Mike

Mitchel SellersUser is Offline
Site Admin/Owner
Guru
Guru
Posts:5490

04/19/2008 11:21 AM  
Typically what I would do in this situation would be to design an interface that provides the core methods, properties needed. Then for each client service simply implement the interface.

Externally you can convert instances of the client services to instances of your interface and then work with them without exception....

-Mitchel Sellers
MCITP, MCPD, MCTS
Director of Development
IowaComputerGurus Inc.

View Mitchel Sellers's profile on LinkedIn

This site is hosted by 3Essentials

To get Guaranteed DNN Support check out our affordable DNN Technical Support Programs
You are not authorized to post a reply.
Forums >Development Discussion >.NET Development > Design Pattern question...



ActiveForums 3.7