MVC,MVP和MVVM有什么区别? [英] What are the differences between MVC, MVP and MVVM?

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

问题描述

从我可以收集到的,前两个看起来不一样。无论是被称为控制器还是演示者,它仍然具有相同的调解功能。



MVVM似乎有点不同,因为控制器似乎更多地是框架,例如与XAML绑定。



这个差异的Cliff's Notes是什么?

解决方案

区别在于模型层中的数据如何在视图实例中结束。




  • 经典MVC (也在Model2 MVC)视图是活动结构。它从模型层请求信息。 控制器仅更改模型图层的状态和视图。

  • MVP 中,视图是被动的。相反,演示者请求模型层的信息并传递视图。您可以阅读更多关于MVP模式的详细信息 here
  • $ b MVVM 中的$ b
  • 类似于MVP,但是 viewmodel 必须在传递信息之前操纵该信息才能查看。



MVP和MVVM之间的区别在于开发过程。当为已知的模型层创建表示层时,您将使用MVP模式。但是您必须使用MVVM,如果您已经存在(或由于某种原因 - 不可更改)的用户界面和预先存在(或不可更改)的模型层。你必须让他们一起工作。这就是viewmodel发挥作用。


From what I can gather, the first two don't seem that different. Whether it's called a controller or presenter, it still seems to have the same mediation functions.

MVVM seems a little different in that the controller seems to be more of a part of the framework, such as with XAML bindings.

What is the "Cliff's Notes" explanation of the differences?

解决方案

The difference is in way how data from model layer ends up in the view instances.

  • in classical MVC (and also in Model2 MVC) view is active structure. It requests information from model layer. Controller only changes the state of model layer and view.
  • in MVP the view is passive. Instead presenter request information from model layer and passes it the view. You can read more extensively on about MVP pattern here.
  • in MVVM is similar to MVP, but the viewmodel has to manipulate the information before passing it to view.

The difference between MVP and MVVM is in the development process. You would use MVP pattern, when creating presentation layer for a known model layer.

But you will have to use MVVM, if you have a preexisting (or for some reason - un changeable) user interface and preexisting (or unchangeable) model layer. And you have to make them work together. That's where viewmodel comes into play.

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

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