Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Design pattern for working with different versions of webservices?

I'm looking for a design pattern to solve an architectual issue I'm having.

I use some webservices that are kinda the same but not exactly. For each new version of the webservices there might be a few more methods available, but for the most part they are basically the same.

I want to write an abstractionlayer that works regardless of which version of the webservices I'm communicating with. Obviously if I'm using a method that only exists in the newer versions of the webservices I will get some sort of error, but that is OK. I can handle those.

The reason I want this abstraction layer is to avoid a tight coupling between my application and the version of the webservices it is communicating with.

What are my options when it comes to design patterns for my abstraction layer? I see there is one pattern called Adapter, and another one called Bridge. Will any of those do in this situation? Any help is appreciated!

Edit - for clarity here is a drawing. enter image description here

Sometimes I want my application to talk to webservices version 1, and other times I want it to use webservices version 2. It depends on who is using the client application.

The client application shouldn't relly know or care which version it is talking to. The only exception is that if it uses a method that is only available in some of the versions I need to handle that gracefully (tell the user that they have installed an old version of the webservices).

like image 887
Frode Lillerud Avatar asked Oct 04 '22 05:10

Frode Lillerud


1 Answers

That would be a factory. You could even use a builtin ChannelFactory or come up with your own. Anyway, a facttory lets you change the implementation without changing client's contract.

like image 108
Wiktor Zychla Avatar answered Oct 13 '22 10:10

Wiktor Zychla