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

被折叠的 条评论
为什么被折叠?



