MVP - 模型视图演示者
我访问了每个 Google 网站、每个教程以及我能在 MVP 上找到的所有内容。一切对我来说都太高了。我想要一些非常基本的东西。大多数 MVP 的内容都是“哦,我们通过创建接口等来解决这个问题”。我想知道为什么要创建这些界面。我想查看示例及其背后的推理,而不仅仅是...这是 MVP 模式的工作原理、使用它...等等。
有什么好的来源吗,或者有人可以在这里解释一下吗?
另外,我真的不知道如何按照这些人所说的方式在 WinForms 中实现数据绑定。用户单击某些内容,单击“保存”,然后调用将该数据保存到数据库的方法,然后返回并重新加载屏幕,这是怎么回事?这不是数据绑定吗?如果是这样,为什么我之前没有看到关于 MVP 中的数据绑定的类似解释的内容。
I have visited every Google'd site, every tutorial, everything I could find on MVP. Everything is too high level for me. I want something VERY basic. Most MVP things go right into, "Oh we solve this by creating an interface, etc". I want to know WHY those interfaces are being created. I want to see examples and the reasoning behind them, not just...here's how the MVP pattern works, use it...etc.
Any good sources for that, or could anyone explain it here?
Also, I really don't know how to implement Data Binding in WinForms the way these people say. What's so wrong with the user clicking on something, clicking save, and then calling a method that saves that data to the database, and comes back and reloads the screen. Is that not databinding? If so, how come I haven't seen something just explain things like that before for DataBinding in MVP.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可以在 Wikipedia 上找到 MVP 的详细概述:
http://en.wikipedia.org/ wiki/Model-view-presenter
基本上,MVP 是经典 MVC 的演变,它本质上提供了一些规则来消除 MVC 中“控制器”含义的歧义。从历史上看,出现了两种类型的控制器:业务逻辑控制器和视图特定控制器(鼠标按下、页面加载等)。
MVP 的运行原理是您的模型部分封装了应用程序的所有业务数据和逻辑。视图层负责所有用户界面事件以及如何向用户显示模型中的数据。 Presenter 层扮演服务器端控制器逻辑的角色——即响应“提交帖子”请求。
注意:MVP 可能更接近 MVC 模式的初衷。
另请参阅 Jeremy Miller 在 2006 年发表的帖子,该帖子帮助介绍了 MVP 概念:
http://codebetter.com/blogs/jeremy.miller/archive/2006/02/01/137457.aspx
自从引入 MVP 概念以来,世界不断发展,Ruby on Rails 教会了世界如何创建可测试的 Web 应用程序并合理地应用 MVC 概念。这些经验教训适用于 MonoRail 和 ASP.NET MVC,并强烈影响了他们的设计。
A good overview of MVP can be found at Wikipedia:
http://en.wikipedia.org/wiki/Model-view-presenter
Basically, MVP is an evolution of the classic MVC, which essentially provides some rules to disambiguate by what is meant by "Controller" in MVC. Historically, there arose two types of controllers: business logic controllers, and view specific controllers (mouse-down, page-load, etc.).
MVP operates on the principle that your Model portion encapsulates all the business data and logic for the application. The View layer is responsible for all user interface events as well as how to display the data in the Model to the user. The Presenter layer takes the role of your server side controller logic--i.e. responding to the "submit post" request.
NOTE: MVP is probably a little closer to what the original intent was for the MVC pattern.
Also take a look at Jeremy Miller's post back in 2006 which helped introduce the MVP concept:
http://codebetter.com/blogs/jeremy.miller/archive/2006/02/01/137457.aspx
Since the MVP concept was introduced, the world evolved and Ruby on Rails taught the world how to create testable web applications and apply the MVC concepts reasonably well. Those lessons made it to MonoRail and ASP.NET MVC, and strongly influenced their design.
您是否阅读过 Phil Haack 帖子 ASP.NET 监督控制器(模型视图演示器) )从原理图到单元测试再到代码?这是一篇关于 MVP 模式以及如何使用它的非常好的文章。
对于 WinForms,请查看SO - Winforms - MVP 示例
Have you read the Phil Haack post ASP.NET Supervising Controller (Model View Presenter) From Schematic To Unit Tests to Code? It's a very good article about the MVP pattern and how to use it.
For WinForms check out SO - Winforms - MVP examples