实用的面向对象的JavaScript设计模式的例子 [英] Examples of practical javascript object oriented design patterns
问题描述
即使没有正式的设计模式,也可以自由发布代码。
我已经编写了大量的JavaScript,但是我没有将很多面向对象的模式应用到我正在做的事情上,我相信我失踪了很多。 >
以下是三种流行的JavaScript模式。由于关闭:
$ b $,这些事情很容易实现b- 模块模式 - Eric Miraglia的示例(和流行的)
- Memoization - Oliver Steele的示例
- Currying - Dustin Diaz的示例
您可能还想查看:
以下是Diaz发布的2008年Google I / O演讲,他从他的书中讨论了一些主题:
What object oriented design patterns do you use in your application's javascript, and why?
Feel free to post code, even if there is no formal design pattern attached to it.
I have written plenty of javascript, but I have not applied much object orientated patterns to what I am doing, and I am sure i am missing a lot.
The following are three popular JavaScript patterns. These happen to be easily implementable because of closures:
- The Module Pattern - Example (and made popular) by Eric Miraglia
- Memoization - Example by Oliver Steele
- Currying - Example by Dustin Diaz
You may also want to check out:
The following is a Google I/O talk from 2008 presented by Diaz, where he discusses some topics from his book:
这篇关于实用的面向对象的JavaScript设计模式的例子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!