惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
S
Schneier on Security
H
Help Net Security
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MongoDB | Blog
MongoDB | Blog
云风的 BLOG
云风的 BLOG
H
Hacker News: Front Page
C
Check Point Blog
P
Privacy International News Feed
IT之家
IT之家
爱范儿
爱范儿
AWS News Blog
AWS News Blog
The Hacker News
The Hacker News
Stack Overflow Blog
Stack Overflow Blog
Project Zero
Project Zero
Microsoft Azure Blog
Microsoft Azure Blog
量子位
The Cloudflare Blog
P
Proofpoint News Feed
Hugging Face - Blog
Hugging Face - Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
C
Cybersecurity and Infrastructure Security Agency CISA
I
Intezer
Martin Fowler
Martin Fowler
Scott Helme
Scott Helme
酷 壳 – CoolShell
酷 壳 – CoolShell
A
Arctic Wolf
T
Threat Research - Cisco Blogs
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Exploit Database - CXSecurity.com
B
Blog
Simon Willison's Weblog
Simon Willison's Weblog
U
Unit 42
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Microsoft Security Blog
Microsoft Security Blog
博客园_首页
J
Java Code Geeks
K
Kaspersky official blog
Webroot Blog
Webroot Blog
C
CERT Recently Published Vulnerability Notes
H
Heimdal Security Blog
G
Google Developers Blog
T
Tor Project blog
W
WeLiveSecurity
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Blog — PlanetScale
Blog — PlanetScale
小众软件
小众软件
有赞技术团队
有赞技术团队

博客园 - thh

svm资料收集 向量空间及其他相关数学结构 难题--autoconf、automake、libtool Linq 中不爽之处 关于UI设计的文章汇总 Window Live Writer LR 剖析器 Guid、Int、BigInt编号的速度和存储空间的比较 静态构造函数线程安全的几个版本[转载] 区域性 ID 2155 (0x086B)不是受支持的区域性 解决方法 windbg给clr设置断点 python ip和int 互转函数 interface与pojo类之间的关系 关于OpenId Python SOAPpy访问asp.net web service 代码 Python SOAPpy 和 .net WebService Type.GetType 获得本Assembly以外的类型 NHibernate 代码生成工具 NHibernate使用笔记
MVP模式中的P和V关系
thh · 2007-10-09 · via 博客园 - thh

   MVP模式实现了View Interface,让Controller代码从View层很好的分离出来,逻辑也更清晰。这个和传统的Page_Load的面条代码相比,有很明显的进步。采用MVP模式之后,Page_load里的代码明显减少了。对于网站开发而言,你可以在dll里写出控制器代码和视图的接口了,以后页面的具体布局,风格也就可以少抄心很多了。但是新问题也产生了:
    1、Presenter 中往往有好多种状态,比如简单的登陆界面,至少有3个状态:登陆前,登陆错误,登陆成功。是应该把这3个状态做成一个View Interface,还是做成3个独立的View Interface呢?按照OO的原则,类应该保持单一的职责,所以选中3个独立的View Interface。但是这个在Asp.net中实现起来好像并不容易。如果设计成一个,那么在View 中,必然存在很多的if,这里简单的称为 界面逻辑。如果状态多了,这些界面逻辑也可能成为一堆面条。所以这里是一个问题。我也看过类似 Response.Redirect的方案,这个增加了Http请求的数目。
      可能的解决办法,是让Presenter支持多个View,增加自动加载视图的功能,类似CakePhp。

   2、事件中调用Presenter的代码问题。如果有一个比较复杂的页面,可能有多个Presenter类,并且页面会响应很多事件。但是如果要仔细的区分这些事件,在Asp.net如果不采用WebControl,做起来就比较的麻烦。因为HtmlControl和Html代码之类的都支持 回发事件,并且在Asp.net中操作不方便。

   以上是我想到的2个问题,也是在实际使用中感觉需要改进的问题。总体来说,MVP模式是基于Asp.net的事件模型的重大改进啊,如果你现在还为Page_Load,OnClick中的重复代码、复杂逻辑感到发愁,建议了解一下MVP模式。

参考:

http://www.codeproject.com/useritems/Advanced_MVP.asp