开发者

Is this a good enough abstraction or I can do better?

开发者 https://www.devze.com 2023-01-31 08:15 出处:网络
Requirement: Requirement is to pull (execute()) a set of data sources. The pulls are are Ordered, can be grouped into small sub groups.

Requirement: Requirement is to pull (execute()) a set of data sources. The pulls are are Ordered, can be grouped into small sub groups.

Design: Each pull is abstracted as a Step. A subgroup is represented as a WaterFallStep because the pull of each of the data source in a group is conditional and follows waterfall model i.e. if 1st data source pull in the group is successful then I' break out of the group.

Questions

  1. Is this a good enough abstraction or i can do better?
  2. How to represent this in JPA 2? I know we can use descriminato开发者_如何学编程rs to map inheritance but my main concern is the 1-to-many relationship between WaterFallStep-to-BasicStep

Thank you.

Is this a good enough abstraction or I can do better?


I think that you should use a composite pattern here. I'd say that each step should handle reference to a collection of steps. If you want yo can move this collection to your WaterfallStep but it still should be a collection of Steps, not BasicSteps and not AbstractSteps.

Concerning JPA you should use OneToMany annotation. There are a lot of examples of usage of this annotation.

Good luck

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号