0
How best to deal with the following problem:
I have an iPhone and Android mobile app that sends and receives data to a Webservice using JSON. My application needs to work offline, with users being able to run for weeks without internet, and when they make connection, the server receives the data and synchronizes.
However, if there is a change in Webservice in the meantime, the expected JSON may change (customer’s requirement). My solution was to make a layer of processing in Webservice that receives the JSON version of the App and converts the data to the format it expects. The problem is that each version that there is such a change requires the treatment layer to be updated for each of the previous versions.
I would like to know whether there is a better method for dealing with this case or whether I am already using the best method.
Grateful.
EDIT:
Being more specific in the treatment layer, I’m treating it as follows:
- AJAX receives JSON from the App via POST, makes a simple validation and passes it for the Appdecodergeral class;
- Appdecodergeral checks the version and instance the class responsible for the respective version of the app (eg Appdecoderandroid70);
- Class Appdecoderandroid70 instance models according to their rules;
- Models are handled by Controllers and Daos, etc;
My problem is in step 3, because I thought about using interfaces, however, an earlier version may not instantiate models that in newer versions are mandatory (for example when a new functionality is implemented).
For now I am continuing to treat case by case, updating each Appdecoder to deal with new features, but I see that so these classes will grow indefinitely.
Is there any better way to handle this case?
Thanks for the feedback Diego, regarding the versioning I’m dealing with this way in the App, what you suggested would Versionar the API too?
– Felipe Andrade
I edited my question to better explain how I’m doing the treatment layer. I created this question precisely because of this inefficiency that you commented, but I still haven’t found a better solution :)
– Felipe Andrade