Clarification :MVC,MVP,MVVM

試著忘記壹切 提交于 2019-12-03 06:23:30

问题


I am reading the difference between MVC,MVP,MVVM

Source: here

My doubt is ,the diagrams (MVP) (MVVM) show bidirectional arrow between Modle and Presenter,Model and ViewModel.

Presenter and ViewModel obviously aware of Model.But does it mean Model is aware of Presenter and ViewModel?


回答1:


Presenter and ViewModel obviously aware of Model.But does it mean Model is aware of Presenter and ViewModel?

No. At least, the way I view these patterns, the Model should (ideally) be unaware of anything except itself. I tried to highlight that in my discussion of MVVM by only showing a uni-directional arrow to the Model.

However, many people use an arrow going both ways to/from the Model to represent events raised by the Model. It somewhat depends on how you see this - the Model will likely need to notify other layers of changes within itself. Depending on the language/framework, this may look like the model "talking" to other layers. However, I try to be very careful to keep this completely neutral from the Model's point of view. For example, in C#, I just use an event, where the types are all Model-specific. It knows "something" may be listening to the event, but does not have any knowledge of what comprises that "something".



来源:https://stackoverflow.com/questions/4751633/clarification-mvc-mvp-mvvm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!