MVC->MVP->MVVM(未完)

本文探讨了MVVM(Model-View-ViewModel)模式,并将其与MVC(Model-View-Controller)和MVP(Model-View-Presenter)进行比较。详细解释了三种模式中Model、View及Controller或Presenter的角色差异。

WPF 引入了MVVM模式。

 

本来就对MVC没有过多了解,这下晕了。

 

MVC至少还听得多,MVC和MVVM Pattern究竟区别何在?为何MS在推出MVC之后,又推出MVP,再推出现在的MVVM.

 

????

 

这个问题得好好想想。

 

----------------------------------------------------

Compare with MVC && MVP

 

http://www.codeproject.com/KB/aspnet/AspNetMvcMvp.aspx

 

http://www.codeproject.com/KB/architecture/MVC_MVP_MVVM_design.aspx (推荐)

 

Sometimes you can hear: MVP is similar to MVC.
Then I have to say, yes, but as similar as is the C# similar to Java. You can read Java code very quickly. But if you’ll be sit to the PC with ‘Eclipse’ instead of Visual Studio, how long will take you to produce ‘Hello World’ application?

First of all we need to correctly ‘localize’ the words in both abbreviations. Look at this two triplets:
Model View Controller
Model View Presenter

For this article we will prefer MVC syntax and adjust MVP.

The first homophone word is Model.

MVC: Model == Plain container for storing references. Model has properties (ValueType, Objects even Collections) but does NOT have methods. This is great advantage of the Model, because whatever information you will need on View, put it in the Model - May be not so obvious but that's so wonderful place for AOP extending...

MVP: Model == Business. Model is not model as in MVC. It in fact represents the Business Facades or Services (or whatever you named it) which allows you to access objects (Entities, DataTables). This Model,bussiness mainly contains methods! Add(), Remove(), Update() ….

The second homophone word is View.  

MVC: View == View represents UI (user interface). View takes care for nice layout, smart controls, images, hyper-links. All that stuff is built from information stored in the model. View exposes Controller's Actions via 'buttons' and 'links'. When they are clicked – MVC directly creates Controller and calls its Action – and the View itself is lost in the past.

MVP: View == Exposes some properties to its presenter, and as presenter executes all needed calls to the Model(Bussiness), assembles itself (View) by filling its exposed properties. The user’s requests are handled by Views methods. In these methods the Presenter is asked to communicate with Model and refill Exposed properties.

The third words are finally different not only by meaning but even by name

MVC: Controller == User requests are primarily routed to the Controller’s Actions. View at this moment only gathers the user inputs, which are transferred into Model. Controller then calls Business to ‘Get’, ‘Update’, ‘Delete’ etc. and refills the Model. Next the View renders the Model’s content.

MVP: Presenter == View creates and asks presenter to get or set data from Model-Business. After Presenter fills all exposed View’s properties, the execution continues on View side.

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值