Data Pull vs. Push OOP Approach

后端 未结 12 966
旧时难觅i
旧时难觅i 2021-01-30 02:41

When I design my system from scratch, I often face a dilemma whether my object should push information into another objects OR whether the objects should

12条回答
  •  感动是毒
    2021-01-30 02:48

    The word push/pull is relative. There will be a pusher who has data and there will be a puller who needs data. If we actually store the data in a neutral place and not inside push-er/pull-er, many possibilities raise that suits a given problem at time.One updates the data when he has it(send notification if necessary) and the other pulls the data at his convenience. Many design patterns, MVC, Observer, Command, etc fall in place to handle the scenario.

提交回复
热议问题