MVC,MVP& MVVM设计模式在编码方面C# [英] What is difference between MVC, MVP & MVVM design pattern in terms of coding c#

查看:110
本文介绍了MVC,MVP& MVVM设计模式在编码方面C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我们使用短语MVC,MVP和MVVM设计模式有什么不同来搜索Google,那么我们可能会得到很少的URL来讨论MVC MVP和MVP之间的区别。 MVVM设计模式理论上像



MVP



在通过数据文本是不可能的。
Windows窗体是一个很好的例子。为了将视图与模型分开,需要一个演示者。由于视图不能直接绑定到演示者,所以信息必须通过接口(IView)传递给视图。



MVVM



在通过数据文本绑定是可能的情况下使用。为什么?每个视图的各种IView界面被删除,这意味着较少的维护代码。
MVVM可能的一些例子包括使用Knockout的WPF和JavaScript项目。



MVC



在视图和其余部分之间的连接的程序并不总是可用的(你不能有效地使用MVVM或MVP)。
这清楚地描述了Web API与发送到客户端浏览器的数据分离的情况。微软的ASP.NET MVC是管理这种情况的一个很好的工具,并提供了一个非常明确的MVC框架。



但是我还没有找到一篇文章,示例代码



如果我得到一篇文章,讨论这3种设计模式(MVC,MVP和MVVM)与代码之间的区别,这将是非常好的。 / p>

我想得到三款类似 CRUD 应用程序的源代码,这些应用程序已经通过这三种设计模式(MVC,MVP & MVVM)。所以我可以通过代码,了解如何为这三个设计模式(MVC,MVP和MVVM)编写代码。



所以如果有这样的文章存在,讨论这些3设计模式(MVC,MVP和MVVM)的代码看起来如何不同,那么请重定向到这篇文章。 / p>

解决方案

这个应该是一个很好的开端。实际上,您所选择的平台在如何使用这些模式方面也起着重要的作用。例如,MVVM自然适合于WPF,而MVP适用于Windows Forms。 ASP.Net MVC自己说话。


If we search Google using the phrase "What is difference between MVC, MVP & MVVM design pattern" then we may get few URL's which discuss the difference between MVC MVP & MVVM design pattern theoretically like

MVP

Use in situations where binding via a datacontext is not possible. Windows Forms is a perfect example of this. In order to separate the view from the model, a presenter is needed. Since the view cannot directly bind to the presenter, information must be passed to the view via an interface (IView).

MVVM

Use in situations where binding via a datacontext is possible. Why? The various IView interfaces for each view are removed which means less code to maintain. Some examples where MVVM is possible include WPF and javascript projects using Knockout.

MVC

Use in situations where the connection between the view and the rest of the program is not always available (and you can’t effectively employ MVVM or MVP). This clearly describes the situation where a web API is separated from the data sent to the client browsers. Microsoft’s ASP.NET MVC is a great tool for managing such situations and provides a very clear MVC framework

But I have not found a single article which discuss the difference theoretically along with sample code.

It would be really nice if i get a article which discuss the difference between these 3 design patterns (MVC, MVP & MVVM) along with code.

I'd like to get my hands on source code of 3 similar CRUD apps which has been implemented by these three design patterns (MVC, MVP & MVVM). So that I can go through the code and understand how one should write code for these three design patter (MVC, MVP & MVVM).

So if any such article exists which discuss how code would look different for these 3 design patterns (MVC, MVP & MVVM) then please redirect me to that article.

解决方案

This should be a good starter. In reality, your chosen 'platform' also plays a large role in how you use these patterns. For example, MVVM is naturally suited to WPF, while MVP works well with Windows Forms. ASP.Net MVC speaks for itself.

这篇关于MVC,MVP& MVVM设计模式在编码方面C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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