MVP(Model View Presenter)或MVC(Model View Controller) [英] MVP (Model View Presenter) or MVC (Model View Controller)

查看:154
本文介绍了MVP(Model View Presenter)或MVC(Model View Controller)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经知道MVP和MVC之间的区别。然后在通过应用程序的SRS之后,我得到一个Fix,需要选择,应用和遵循Applcation Architecture。
根据我的理解,我会选择MVP,那里有来自超过2个GUI的使用相同业务逻辑的机会。像一个公开(www)和Adming(winform)部分的应用程序。
如果没有这样的...找MVC。因为我可以更精确地跟随工厂图案。



Dudes,我不知道,但是我觉得我只是玩盲注,如果我必须选择它们。我需要知道。你有什么意见?



注意:我遵循.net和C#。

解决方案在我看来,模型视图控制器模式的所有变体的差异( MVP 被动视图监督控制器,查看模型,)相当微妙。这是关于谁处理数据,并从数据中获取数据。他们都在努力解决同样的问题,从另一件事情分离出某些 ,解决方案以类似的方式做到这一点。



几乎显而易见的是,当您在视觉上考虑时,这些概念在实现中是相似的:

 简单的MVC:

+ ------- +操纵数据
|模型|< --------------------- +
+ ------- + |
| |
|获取数据|
v |
+ ------------ +提供数据+ ------ +
|控制器| -------------> |查看|
+ ------------ + + ------ +

简单MVP:

+ ---- --- +
|模型|
+ ------- +
| ^
| |获取/操作数据
v |
+ ----------- +服务数据+ ------ +
|演示者| --------------> |查看|
| |< -------------- | |
+ ----------- +告知变更+ ------ +

它们在类层次结构中可能看起来相同。不同之处在于显示和操纵数据的不同方式。当你推出自己的MVC时,你负责它应该是如此的。



这并不重要,因为它们都基于将代码段分离成自服务逻辑实体并减少代码复制的原理。只要你保持代码耦合低,它应该很好地结束了。只需要根据您的应用程序的架构,就可以做到这一点。



请务必务实,最适合您的需求。一个混合反正。根据视图需要,在变化之间切换应该是相当的。按照 SOLID 原则,你应该做的很好。 (另见关于SOLID )。



我建议您查看是否有MVC或MVP框架来看看它是如何完成的。


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?

Note: I follow .net and C#.

解决方案

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 +------+

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.

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.

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).

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

这篇关于MVP(Model View Presenter)或MVC(Model View Controller)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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