I came across the following scenario at my work. Looking forward to hear thoughts on the same scenario for better maintainability in future.
I have a converter of a legacy model of one system to the expected model by an API. There is always sevices available for one leagcy system and now comes the new legacy system whose model also needs to go through exact same set of operation to get converted to the expected model by the upstream api.
Currently I have a request model which goes to different service to get differently transformed based on its type. Now, I need to have the similar thing for a new request model
So, I have Basically
- Operations Common for all type irrespective of request model
- Operations Common for all type and depends on request model(getter methods will be diff in diff request model)
- Operations for specific type irrespective of request model
- Operations for specific type and depends on the request model
I want to have right set of abstract services so that in future on-boarding a new legacy system becomes easy.
So Here is what I did which I'm unsure if its cleaner approach. 1) and 3) tied with inheritance and 2) is tied with composition to the most specific implementation. Since I have abstract class as autowire things in there, I need state so couldn't use multiple inheritance.
1) AbstractCommonOperationsforAllTypeIrrepctiveInput<T>
|
3) AbstractCommonOperationsforSpecificTypeIrrespectiveInput extends
AbstractCommonOperationsforAllTypeIrrepctiveInput<T>
2) AbstractCommonOperationsforAllTypeDependsOnInput<T>
CommonOperationsforSpecificTypeDpendsOnModel1Helper extends
AbstractCommonOperationsforAllTypeDependsOnInput<Model1>
CommonOperationsforSpecificTypeDpendsOnModel2Helper extends
AbstractCommonOperationsforAllTypeDependsOnInput<Model2>
4)
SpecificOperationsForSpecificType extends
AbstractCommonOperationsforSpecificTypeIrrespectiveInput<ReuqestModel1>
- CommonOperationsforSpecificTypeDpendsOnModel1Helper
SpecificOperationsForSpecificType extends
AbstractCommonOperationsforSpecificTypeIrrespectiveInput<ReuqestModel2>
- CommonOperationsforSpecificTypeDpendsOnModel2Helper
Please share your thought on this.
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire