design pattern 's question

gorge_an 2001-08-08 12:05:32
about prototype (原型).
大家好。 在学习design pattern的时候。我对prototype (原型)的具体用途不是很清楚。书上说是为了减少subclass的个数。但是我看好想不是的。希望读过该书的
大虾给我一些提示。希望可以具体的讲一下prototype 的思想!
谢谢了先!
...全文
155 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
dbbdggdbbdgg 2001-09-09
  • 打赏
  • 举报
回复
关于Pattern的资料,什么都有

http://www.umlchina.com/Pattern/Newindex1.htm
one_add_one 2001-08-11
  • 打赏
  • 举报
回复
gz
jbtan 2001-08-10
  • 打赏
  • 举报
回复
prototype pattern 的确可以减少subclass的数量,但这是后果,而不是目的。我们不能仅仅因为要减少subclass而使用prototype. 此外,如果创建一个对象是耗时操作的话, 我们使用prototype。例如,一个class A的实例包括一个极为复杂(耗时)的查询,而我们需要在不同的地方使用查询结果(当然,可能要求不同的排序或者字段),那么可以通过“克隆”(deep copy or clone)这个实例来得到新的对象,而不是创建A的subclass(比如,仅仅是排序不一样), 去重复耗时操作来得到一个新对象。不限于上述。
请指正。
gorge_an 2001-08-10
  • 打赏
  • 举报
回复
ok thank you
!
gorge_an 2001-08-09
  • 打赏
  • 举报
回复
up
Description What's the best approach for developing an application with JavaScript? This book helps you answer that question with numerous JavaScript coding patterns and best practices. If you're an experienced developer looking to solve problems related to objects, functions, inheritance, and other language-specific categories, the abstractions and code templates in this guide are ideal -- whether you're writing a client-side, server-side, or desktop application with JavaScript. Author Stoyan Stefanov includes several examples for each pattern as well as practical advice for implementing them. What's the best approach for developing an application with JavaScript? This book helps you answer that question with numerous JavaScript coding patterns and best practices. If you're an experienced developer looking to solve problems related to objects, functions, inheritance, and other language-specific categories, the abstractions and code templates in this guide are ideal -- whether you're writing a client-side, server-side, or desktop application with JavaScript. Written by JavaScript expert Stoyan Stefanov -- Senior Yahoo! Technical and architect of YSlow 2.0, the web page performance optimization tool -- JavaScript Patterns includes practical advice for implementing each pattern discussed, along with several hands-on examples. You'll also learn about anti-patterns: common programming approaches that cause more problems than they solve. * Explore useful habits for writing high-quality JavaScript code, such as avoiding globals, using single var declarations, and more * Learn why literal notation patterns are simpler alternatives to constructor functions * Discover different ways to define a function in JavaScript * Create objects that go beyond the basic patterns of using object literals and constructor functions * Learn the options available for code reuse and inheritance in JavaScript * Study sample JavaScript approaches to common design patterns such as Singleton, Factory, Decorator, and more * Examine patterns that apply specifically to the client-side browser environment

1,268

社区成员

发帖
与我相关
我的任务
社区描述
软件工程/管理 管理版
社区管理员
  • 研发管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧