jQuery 范例?
在我看来,jQuery 似乎并不是作为一个 OOP 框架编写的,它似乎太短了,而且不够详细。我的想法是否正确?如果它不是以 OOP 形式编写的,那么他们使用的是什么方法/范式?
It seems to me that jQuery doesn't seem to be written as an OOP framework, it seems too short, and not verbose enough for that. Am I right in thinking this and if it isn't written as OOP, then what methodology/paradigm are they using?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我怀疑该方法是:使其尽可能小且尽可能快。
I would suspect the methodology to be: make it as small and as fast as possible.
他们使用函数式编程范例。
它很小,很简单,而且速度很快。
They use the functional programming paradigm.
It's tiny, it's straightforward, and it's fast.
jQuery 的行为类似于 monad。 Monad 通常用于函数式编程语言(例如 Haskell),但不限于此。请参阅http://importantshock.wordpress.com/2009/ 01/18/jquery-is-a-monad/
我不愿意说 jQuery 使用函数式编程范式,因为它是非常有状态的,而函数式程序试图避免这种情况。
jQuery behaves like a monad. Monads are usually used in functional programming langauges such as Haskell, but are not limited to them. See http://importantshock.wordpress.com/2009/01/18/jquery-is-a-monad/
I'm reluctant to say jQuery uses the functional programming paradigm because it is very stateful, which functional programs try to avoid.
不,jquery 并不是为了成为一个 oo 框架而编写的。这一切都是为了抽象 dom 和 ajax。这是一篇关于 jquery 和 mootools 之间差异的精彩文章: http://jqueryvsmootools.com/
No, jquery isn't written to be a oo framework. It is all about abstracting the dom and ajax. Here is a great article about the differences between jquery and mootools: http://jqueryvsmootools.com/