MVP(模型 - 视图 - presenter)或MVC(模型 - 视图 - 控制器) [英] MVP (Model View Presenter) or MVC (Model View Controller)

查看:173
本文介绍了MVP(模型 - 视图 - presenter)或MVC(模型 - 视图 - 控制器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经知道的MVP和MVC之间的差异。然后,还可以通过一个应用程序我在修复其中一个需要被拾起得到的SRS去后,应用,其次为建筑的applcation。
按我的理解,我会选MVP那里是使用相同的业务逻辑,从超过2 GUI的机会。像与公共(WWW)和Adming(WinForm的)一部分的应用程序。
如果没有这样的......寻找MVC。因为我可以按照厂patters更准确。

I already know the difference between MVP and MVC. Then also after going through the SRS of an application i get in a Fix which one need to be picked, applied and followed as Applcation Architecture. As per my understanding I would pick MVP where there is the chances of using the Same Business Logic, from more than 2 GUIs. Like for a application with a public (www) and Adming (winform) part. If there is not such ... look for MVC. Because I can follow Factory patters more accurately.

花花公子,我不知道,但我觉得我只是扮演盲拍,如果我得到了他们中间进行选择。我需要知道。你们有过这些什么意见?

Dudes, I don't know but I feel like I just play blind shot if I would got to choose among them. I need to know. What opinion you guys have over these?

请注意:我关注.NET和C#

Note: I follow .net and C#.

推荐答案

在我心中的模型视图控制器模式的所有变化的差异(的 MVP 被动视图,<一个HREF =htt​​p://martinfowler.com/eaaDev/Supervising$p$psenter.html相对=nofollow>监督控制器,视图模型,的等。)是相当微妙的。这是所有关于谁处理数据,并采取从谁的数据,真的。他们都试图解决同样的问题,从分隔条件的的东西另一件事的和解决方案做的一切,以类似的方式。

In my mind the differences for all variations of Model View Controller patterns (MVP, Passive View, Supervising Controller, View Model, etc.) are quite subtle. It's all about who processes the data and takes the data from who, really. They are all trying to solve the same problem, seperating something from another thing, and the solutions do all that in a similar fashion.

这几乎是公然明显的概念在实施类似的,当你在视觉方面想一想:

It is almost blatantly obvious that the concepts are similar in implementation when you think about it in visual terms:

Simplistic MVC:

+-------+       manipulates data
| Model |<---------------------+
+-------+                      |
    |                          |
    | gets data                |
    v                          |
+------------+ serves data  +------+
| Controller |------------->| View |
+------------+              +------+

Simplistic MVP:

+-------+
| Model |
+-------+
  |  ^
  |  | get/manipulates data
  v  |
+-----------+  serve data   +------+
| Presenter |-------------->| View |
|           |<--------------|      |
+-----------+  tell changes +------+

他们是在类层次结构可能看起来相同的两个相似。然而所不同的是显示和操作数据的不同方式。当你推出自己的MVC,然后你负责的,应该怎么样子。

They're similar in that class hierarchy may look the same in both. The difference however are the different ways of displaying and manipulating data. When you're rolling out your own MVC then you're in charge of how it should look like.

它并不真正的问题那么多,因为它们都是基于分隔条件code片为自我服务的逻辑实体,并减少code重复的原则。只要你保持 code低耦合它应该制定出很好最后。如果你想与您的应用程序体系结构随之而来的教条,只重要的。

It doesn't really matter that much since they are all based on a principle of seperating pieces of code into self serving logic entities and reducing code duplication. As long as you keep the code coupling low it should work out nicely in the end. It only matters if you want to be dogmatically consequent with your application's architecture.

务实它做什么适合自己需要的最好的,因为你会混合反正告终。它应该是相当易取决于什么的视图需要变化之间切换。按照<一个href=\"http://www.lostechies.com/blogs/derickbailey/archive/2009/02/11/solid-development-principles-in-motivational-pictures.aspx\"相对=nofollow> SOLID 原则,你应该做的罚款。 (参见这一下SOLID )。

Be pragmatic about it and do that what suits your needs the best since you'll end up with a mix anyway. It should be "fairly" easy to switch between the variations depending on what the view needs. Follow the SOLID principles and you should do fine. (See also this about SOLID).

我建议你看看,如果有MVC或MVP框架来看看它是如何完成的。

I would suggest you look into if there are MVC or MVP frameworks to see how it is done.

这篇关于MVP(模型 - 视图 - presenter)或MVC(模型 - 视图 - 控制器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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