What is the correct template for providing client-server backward compatibility?

I am developing a client-server application and cannot make users not use older versions of the client or even other clients, since the protocol is WebDAV.

I need them all to support with some backward compatibility, so the server side will behave differently, depending on which version of the client it is running on.

My question is how to prepare my application for this situation before running into this. Do I need to use a design template? How to create backward compatibility?

+3
source share
3 answers

API (Facade ) , .

, API, A, B C. -. , . ( 1) A, B C. ...

, D, B C. ( 2), A, D C. -, D, B "", C - , . , . C -, . , , ...

- ( ) -, .

+3

, , Design Patterns.

, Facades -,

MyServiceV1  { // the original interface

MyServiceV2  { // the new interface 

.. , , . , , -

createItem( String name,
            Integer value);

 createItem( String name,
            Integer value,
            String justification
 );

, v1 , "", ? , "UNKNOWN", , , - , -. , , .

, , , chnages. , , , .

+2

, , , .

... :

  • Server .
  • Server, Server ClientConnection . , , ClientConnection.
  • each ClientConnectionmanages all messages between Serverand a separate remote client host.
  • the first thing that does ClientConnectionis negotiate with the remote client and find out which version. once this is done, it ClientConnectionwill create an appropriate implementation ServerBehaviorStrategyto handle all subsequent messages ClientConnection.

UML Class Class Diagram

Thus, all programming of specific behaviors is purely isolated in individual implementations of the interface ServerBehaviorStrategy.

0
source

Source: https://habr.com/ru/post/1787912/


All Articles