Wednesday, May 23, 2012

Best practices for API backwards compatibility

I'm working on an iPhone/iPad/Android app which communicates with a JSON API.

The first release of the version of the app is complete, and now additional phases of development are taking place. In the additional phases, the app needs to integrate with a new version of the API and allow the user access to additional features such as new screens or modified behaviour within existing screens. The app does however need to be backwards with previous versions of the API.

What is the best practice for tackling such a requirement?
I could of could do checks throughout the code:

if (APIVersion == 1) {

} else if (APIVersion == 2) {

} else if (APIVersion == ....) {


But I'm concerned about the scalability of this approach.
The factory method comes to mind but I'm not sure how far this would get me.


No comments:

Post a Comment