Home  /  Questions  /  Question



54   94.6
Jan 08, 2013


Adapter or Proxy?

In a case where there are 3 classes and i need to choose 1 of the class to use. Then by using a standard method, i can access the file. The reason of having 1 standard method is to prevent re-writing of codes if different protocol is used. Example, I have 3 classes called MAPI, WebDAV, EWS. Each class has their own method of retrieving information from Exchange Server. I want to have a class that have all the standard method to access each class. As a system admin, 1st i select which protocol to use, then i select what process the system should do (Retrieve information, update information etc). This way, the system admin does not need to have programming knowledge because he/she does not have to edit the code each time he/she change protocol. Which design pattern should i use? Should i use the Adapter design pattern or Proxy design pattern? I am currently using Proxy design to design where there is a abstract class and another 3 of the classes, A B and C, and 1 additional class, Manager class, inherit the methods in abstract class.I use Manager class to manage access to either 1 class. But then when i look at Adapter pattern, it seems like a better choice. Which should i use?



Jan 10, 2013
Hi Chris
From your description it does not seem that either pattern would apply. However since there is a decision point (i.e. the protocol used) based on which a particular course of action i.e. method of retrieving information is used, it would seem that the strategy pattern would be best suited in this situation.

Vik