vendredi 18 septembre 2015

Using adaptor vs proxy for integration with multiplae providers

I'm going to integrate with more than one provider and each one have different interface, so I have 2 options and want to chose one of them:

1- using adaptor so inside my application will have interface contains all methods with parameters I'm expecting, and when get provider API will make adaptor for this API by implementing the interface from my application.

2- using universal proxy proxy implement specific interface "could be the interface specified in adaptor option" and this proxy will have to call provider API and provide the methods for my application to use it

Note 1: you may think that 2 options are the same but it is not, in adaptor you are expecting that the provider api will have same methods you have in different names and same parameters but may be will need to be cast, in proxy you have more flexibility from the side of provider so provider can be what ever java api, REST service or anything else.

Note 2: the contract between me and provider api in option 1 is business common understanding, but in option 2 it is code interface have to be implemented

Note 3: I can have both in one solution, proxy inside my application and use adaptor to call provider API and if provider API is not matching our Business common understanding will make another proxy over it like :

Provider => proxy => adaptor => proxy

but do I need that rather than using only proxy to wrap all of this?

Aucun commentaire:

Enregistrer un commentaire