MVP: Is it the View or the Presenter that should know of the Model?

后端 未结 4 518
名媛妹妹
名媛妹妹 2021-02-04 18:02

Relatively new to patterns, let me straight away show an example in the context of WinForms.

I have a basic MVP Passive View structure, which one should I go ahead with:

4条回答
  •  臣服心动
    2021-02-04 18:21

    What's wrong if view knows model? After all UserView is made specifically for UserModel isnt it?

    Nothing. It's accepted practice in the Supervising Controller variant of the MVP pattern. The view interacts directly with the model for simple operations while more complex operations are marshalled throught the presenter. While in Passive View, everything goes through the presenter.

    Additionally, see Jeremy Miller's Build your own CAB series to get a better idea on the differences between the two approaches: Supervising Controller and Passive View.

提交回复
热议问题