I have to call several services having multiple API's. Few of them are basically read(they return me some data) and few of them change the state of several objects(they basically update the state of the several objects).
I am looking for a design pattern which can be applied to the above scenario.
Code Example Lets take a small example of a service A
AccountInfo A.getAccountInfo()
void A.setAccountData(AccountInfo)
AccountStatus A.getStatusForAccount
...
I thought of having a Generic Interface
interface CallAPI {
public Output execute(Input)
}
Each API call would implement this interface and I can use Factory pattern to get instances of the API's.
I would like to know if there is a better pattern for the same or it can be refactored in a different way. The APIs and services would only increase and it should be easier to set up new APIs and the clients should not have additional overhead to writing adapters for new APIs.
Aucun commentaire:
Enregistrer un commentaire