什么是MVC和MVVM之间的异同? [英] What are the differences and similarities between MVC and MVVM?

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

问题描述


  

可能重复:结果
  是什么MVC和MVVM之间的区别?


我Asp.Net MVC模式是新的。我只是有关于MVC和MVVM几个问题


  1. 哪些问题做这些模式地址?

  2. 他们如何相似?

  3. 他们如何不同?


在ASP.NET MVC
解决方案

请求从Web服务器进来,由控制器直接处理。控制器确定适当的查看和使用模型填充它。控制器然后释放这些实例这使得结果到客户端的基础系统。你可以看到,控制器是第一和最后一个动作。

在MVVM,用户界面​​(视图),面对用户,直接接受用户输入。在视图,视图模型(这是视图的DataContext的)中的命令是由这一活动引发的。控制流入其中除$ P $其中pts什么查看已派出它和prepares其模型视图模型。控制流回查看后,根据模型的变化更新自己。 UI组件 - 如果需要一个新的视图,视图模型用的NavigationService(或其他导航方法应用程序使用),它是窗口或框架的范围传达这一点。你可以看到,该视图模型是不是第一个和最后行事;查看起着比MVC更大的作用。

至于选择哪一个是最好的,我会倾向于由工具支持的指导。举例来说,如果你正在使用ASP.Net,还有就是通过MVC项目模板,与锅炉板安装和使用该模式的应用程序可帮助自动化的大量。据我了解有关Silverlight / WPF,有一个很大的支持有没有解决MVVM。当我在几年前,来了就MVC / MVP的速度,我在一个电子商务应用程序的结帐过程实现的MVP。这是一个令人满意的结果,一个伟大的经验,但我写的手都没有工具支持和指导很少。当我写一个Silverlight应用程序,我肯定会朝着MVVM因为那是有支撑移动。

Possible Duplicate:
What is the difference between MVC and MVVM?

I am new in Asp.Net MVC pattern. I just have few questions related to MVC and MVVM

  1. What issues do these patterns address?
  2. How are they similar?
  3. How are they different?

解决方案

in ASP.NET MVC the request comes in from the web server and is handled directly by the Controller. The Controller determines the appropriate View and populates it with Models. The Controller then releases these instances to the underlying system which renders a result to the client. You can see that the Controller is first and last to act.

In MVVM, the UI (the View), faces the user and takes user input directly. Within the View, Commands within the ViewModel (which is the DataContext of the View) are triggered by this activity. Control flows to the ViewModel which interprets what the View has sent it and prepares its Models. After control flows back to the View it updates itself according to changes in the Models. If a new View is required, the ViewModel communicates this with the NavigationService (or whatever method of navigation your application uses), which is the purview of the Window or Frame--UI components. You can see that the ViewModel isn't first and last to act; the View plays a much greater role than in MVC.

As far as choosing which one is best, I would tend to be guided by tooling support. For instance, if you are using ASP.Net, there is a tremendous amount of automation through the MVC project template that helps with the boiler plate setup and use of that pattern in an application. From what I understand about Silverlight/WPF, there is a lot of support there around MVVM. When I was coming up to speed on MVC/MVP a few years ago, I implemented MVP in the checkout process of an eCommerce application. It was a great experience with a satisfying outcome, but I was writing everything by hand with no tooling support and little guidance. When I write a Silverlight app, I will certainly be moved toward MVVM because of the support that is there.

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

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