Data Pull vs. Push OOP Approach

后端 未结 12 767
旧时难觅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 03:06

    The answer depends on your architecture goals, in other words there is no general solution.

    In a client server architecture you likely will have a layered system on the backend where objects pull state from other objects. That means only certain "services" will in the end update the state of an object. Example: creating a new object, updating a field of an object etc. (Like adding a new order item to the total order).

    In monolithic desktop application it might be completely different. You likely use "Model-View-Controller" variations and observer patterns etc. In this case you push info e.g. to the UI.

提交回复
热议问题