MVP(Model View Presenter)或MVC(Model View Controller) [英] MVP (Model View Presenter) or MVC (Model View Controller)
问题描述
根据我的理解,我会选择MVP,那里有来自超过2个GUI的使用相同业务逻辑的机会。像一个公开(www)和Adming(winform)部分的应用程序。
如果没有这样的...找MVC。因为我可以更精确地跟随工厂图案。
Dudes,我不知道,但是我觉得我只是玩盲注,如果我必须选择它们。我需要知道。你有什么意见?
注意:我遵循.net和C#。
几乎显而易见的是,当您在视觉上考虑时,这些概念在实现中是相似的:
简单的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屋!