I'm writing an application that uses API's of different social networks such as Twitter, Tumblr, Vimeo, etc. All these networks work with the OAuth format for authentication and the JSON format for data response. This means that, besides the general program as such, there are large segments of code that apply to all networks.
However there are also bound to be some particularities. For example Tumblr has implemented part of it's API through a single key authentication instead of full OAuth. And there may also be differences in the methods that are relevant for each network.
So my question is: How can I create on the one hand a generic code structure that shares code where possible, but on the other hand facilitate specific elements for each network?
I believe the former is quite easy to do through classes and if needed inheritance, however it's mainly the latter I'm struggling with in the context of a generic code structure.
Concrete example
I have a Network class, which contains different objects for things like the icon and the authentication keys. So far these are all generic, but can be applied fine to each network (because the content differs but the type and methods are identical). Now I intend to add some kind of API object to each network. Suppose I have different TwitterAPI, VimeoAPI etc. classes (perhaps extending a BaseAPI class to share code). How would I be able to declare, initialize and call specific methods from a SpecificAPI class within a generic code structure?
Is there anybody who can shed some light on this?
However there are also bound to be some particularities. For example Tumblr has implemented part of it's API through a single key authentication instead of full OAuth. And there may also be differences in the methods that are relevant for each network.
So my question is: How can I create on the one hand a generic code structure that shares code where possible, but on the other hand facilitate specific elements for each network?
I believe the former is quite easy to do through classes and if needed inheritance, however it's mainly the latter I'm struggling with in the context of a generic code structure.
Concrete example
I have a Network class, which contains different objects for things like the icon and the authentication keys. So far these are all generic, but can be applied fine to each network (because the content differs but the type and methods are identical). Now I intend to add some kind of API object to each network. Suppose I have different TwitterAPI, VimeoAPI etc. classes (perhaps extending a BaseAPI class to share code). How would I be able to declare, initialize and call specific methods from a SpecificAPI class within a generic code structure?
Is there anybody who can shed some light on this?
1