澄清:MVC,MVP,MVVM [英] Clarification :MVC,MVP,MVVM

查看:79
本文介绍了澄清:MVC,MVP,MVVM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读MVC,MVP,MVVM之间的区别

I am reading the difference between MVC,MVP,MVVM

来源:此处

我的疑问是,图表(MVP)(MVVM)在Modle和Presenter,Model和ViewModel之间显示了双向箭头.

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

Presenter和ViewModel显然知道Model,但这是否意味着Model知道Presenter和ViewModel?

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

推荐答案

Presenter和ViewModel显然知道Model,但这是否意味着Model知道Presenter和ViewModel?

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.

但是,许多人都使用往返于模型的双向箭头来表示模型引发的事件.这在某种程度上取决于您如何看待-该模型可能需要将自身内的更改通知其他层.取决于语言/框架,这可能看起来像模型与其他层交谈".但是,从模型的角度来看,我会尽量保持完全中立.例如,在C#中,我仅使用一个事件,其中的类型都是特定于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".

这篇关于澄清:MVC,MVP,MVVM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆