I need to create a system which will communicate with different systems of our customers. There will be a domain layer which will make different calculations but to keep it simple let’s go with only one function called “GenerateToken”, which has an algorithm to create an access token.
We have different types of customers using different versions of APIs. To make easier to visualize, I will try to explain with an example:
1.Company A is X type of customer – uses API v.1.0
2.Company B is X type of customer – uses API v.1.1
3.Company C is Y type of customer – uses API v.2.0
4.Company D is Z type of customer – uses API v.1.0
5.Company E is X type of customer – uses API v.1.1
6.Company F is Z type of customer – uses API v.2.0
If versions of the APIs and company types are same, it means way to generate token is same. For example; “GenerateToken” function will take same parameters and has the same algorithm for 2nd and 5th cases in the example. “GenerateToken” is just an example and it will have much more calculations in the future, that means one of the most important thing will be extendibility (Open close principle) for the design.
My question is that I couldn’t decide what kind of architecture or design pattern I should go with. I can create a parent class with “GenerateToken” and then override it from child functions(Polymophism) or use something similar to “Factory Method Pattern”. However in these cases I will need to create a class for almost each company type with API version (class TypeXApiV1.0, TypeXApiV1.1, TypeYApiV1.0 etc.), which feels silly.
What would you suggest for this solution or is there any design pattern I can use. I hope I could explain the situation. If there is something I am missing or didn’t explain clearly please let me know. Thank you.
Aucun commentaire:
Enregistrer un commentaire