Zend 框架中使用的设计模式
我正在准备谈论Zend Framework
的总体架构,并想总结一下其中使用的设计模式。
我相信这对于那些了解ZF
和学习DP
的人,以及对于那些了解DP
和学习ZF<的人来说都是有益的/代码>。在前一种情况下,人们将能够看到模式的现实世界应用,并在第二种情况下更好地理解框架。
即使是 Zend_Contoller_Front: Singleton
形式的简短答案也足够好了,如果提供一些详细说明(对于一些不太明显的情况),那就更好了。
我主要对 GoF
模式感兴趣,因为它们似乎是任何 DP 冒险的起点。
UPD:没有直接相关,但对于那些了解Java
的人来说,有针对在 Java
核心中找到的 GoF
的 DP
示例的极其完整的答案。
I am preparing talk about general architecture of Zend Framework
, and wanted to summarize Design Patterns used in it.
I believe it will be beneficial both for those knowing ZF
and learning DP
s, and for those knowing DP
s and learning ZF
. In a former case, one would be able to see real-world application of patterns, and get a better comprehension of framework in the second.
Even brief answers in a form Zend_Contoller_Front: Singleton
are good enough, if a little elaboration is provided (for some not-so-obvious cases) it will be even better.
I am primary interested in GoF
patterns, as they seem to be the starting point of any DP-adventure.
UPD: Not directly related, but for those who know Java
there's extremely complete answer for GoF
's DP
examples found in Java
core.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
由于现在这是一个 CW,我将添加我在评论中给出的模式:
Zend_Controller_Front
单例
FrontController
Zend_Db_Table
表数据网关
Zend_Log
工厂方法
适配器
复合
Zend_Form
复合
装饰器
Zend_Filter
和Zend_Validator
策略
Since this is a CW now, I'll add the patterns I already gave in the comments:
Zend_Controller_Front
Singleton
FrontController
Zend_Db_Table
Table Data Gateway
Zend_Log
Factory Method
Adapter
Composite
Zend_Form
Composite
Decorators
Zend_Filter
andZend_Validator
Strategy
列举一些模式:
Zend_Controller_Front
中的前端控制器模式 (index.php + .htaccess)Zend_Registry
中的注册表模式Zend_Application_Bootstrap_Bootstrap
容器中的依赖注入grep getInstance
中)Zend_Form
验证器中的策略模式Zend_Form
装饰器中的装饰器模式| 中的适配器模式grep 适配器
文件和方法名称很明显,因此
grep
是您的朋友。有志愿者编辑并提供链接和示例代码吗?
To name some patterns:
Zend_Controller_Front
(index.php + .htaccess)Zend_Registry
Zend_Application_Bootstrap_Bootstrap
's containergrep getInstance
)Zend_Form
's validatorsZend_Form
's decorators| grep adapter
File and method names are obvious, so
grep
is your friend.Any volunteer to edit and provide the links and sample code?
为了提供我想要的样本,并帮助那些怀疑我要求别人做我的跑腿工作的人更好地评估这个问题的答案是否对其他人有帮助(无论是尝试学习 DP 还是 ZF),这里是示例:
工厂方法模式:
To provide a sample of what I want, and to help those who suspect I am asking others to do my leg-work evaluate better whether answers to this question might be helpful to someone else (either trying to learn DPs or ZF), here is sample:
Factory Method Pattern:
为了完整起见,应该注意 Zend_Form 使用了一种修改后的装饰器模式。在 Zend_Form 中,生成的内容被装饰,而不是对象本身。
来源:http://devzone.zend.com/1240/decorators-with-zend_form/
For completeness, one should note that Zend_Form uses a modified decorator pattern. In Zend_Form, the generated content is decorated and not the object itself.
Source: http://devzone.zend.com/1240/decorators-with-zend_form/