我已经搜索了很多MVP,但我没有找到任何有助于我理解它的好文章。有没有人知道有关这个主题的任何好文章,有真实世界的例子来帮助我更好地理解它?
提前致谢。
答案 0 :(得分:4)
查看我对该帖子的回答,这可能对您有所帮助:
Is ASP.net Model View Presenter worth the time?
它经历了MVP和MVC之间的差异,因为两者经常形成对比 此外,还有一些有用的链接,展示了如何轻松地将MVP模型融入现有的ASP.Net网站。
HTH
答案 1 :(得分:3)
ASP.NET Supervising Controller (Model View Presenter) From Schematic To Unit Tests to Code
Simplest example of MVP design patter of Asp.net
Model View Presenter with ASP.NET
Very Quick MVP Pattern to Use with ASP.NET
<强>被修改强>
还有一个链接: Model View Presenter (MVP) Design Pattern with .NET - Winforms vs. ASP.NET Webforms
答案 2 :(得分:3)
这是一个致力于在asp.net上执行mvp的网站:http://webformsmvp.com/ MVP作为一种模式有点过时了 - MVC(它有一个很棒的asp.net框架和支持)和MVVM(事实上的WPF模式)已经基本上接管了。事实上,Martin Fowler(MVP的发明者)已经证明,该模式确实应该分为两种模式:Passive View和Supervising Controller在他的网站上:http://martinfowler.com/eaaDev/ModelViewPresenter.html
答案 3 :(得分:1)
如果您想了解更多信息,请查看 Web客户端软件工厂2010 工具。
此工具主要用于创建复合Web应用程序(模块),但视图是使用MVP模式实现的。如果您要维护传统的ASP.Net代码,或者如果您想在ASP.Net范例中进一步挖掘,那么检查此工具的源代码是一个很好的起点。
此工具要求您安装Visual Studio的几个扩展,然后,您可以创建一个特殊的Web项目,为您实现MVP,它将向Visual Studio添加上下文菜单以方便任务
示例:
检查默认生成的代码:
public partial class MyNewView : Microsoft.Practices.CompositeWeb.Web.UI.Page, IMyNewViewView
{
private MyNewViewPresenter _presenter;
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this._presenter.OnViewInitialized();
}
this._presenter.OnViewLoaded();
}
[CreateNew]
public MyNewViewPresenter Presenter
{
get
{
return this._presenter;
}
set
{
if (value == null)
throw new ArgumentNullException("value");
this._presenter = value;
this._presenter.View = this;
}
}
// TODO: Forward events to the presenter and show state to the user.
// For examples of this, see the View-Presenter (with Application Controller) QuickStart:
//
}
public interface IMyNewViewView
{
}
public class MyNewViewPresenter : Presenter<IMyNewViewView>
{
// NOTE: Uncomment the following code if you want ObjectBuilder to inject the module controller
// The code will not work in the Shell module, as a module controller is not created by default
//
// private IShellController _controller;
// public MyNewViewPresenter([CreateNew] IShellController controller)
// {
// _controller = controller;
// }
public override void OnViewLoaded()
{
// TODO: Implement code that will be executed every time the view loads
}
public override void OnViewInitialized()
{
// TODO: Implement code that will be executed the first time the view loads
}
// TODO: Handle other view events and set state in the view
}
抓住工具的战利品:
如果您有兴趣,我认为有一个改进现有应用程序以使用Web客户端软件工厂的工作