JavaScript Spessore

0
(0)

JavaScript Spessore
 

  • Author:raganwald
  • Length: 340 pages
  • Edition: 1
  • Publisher: Leanpub
  • Publication Date: 2014-06-24
  • Download:Register/Login to Download
  • Buy Print:Buy from amazon


    Book Description

    JavaScript Spessore celebrates “Thinking in Objects,” starting with the basics, building upon them, and then exploring new ways to think about object-oriented programming.

    0, 1, ∞

    To truly think in objects, you have to liberate yourself from thinking in terms of any one language’s features, because there is more than one way to “do” objects and object-oriented programming. Let’s compare a few other languages to JavaScript:

    • Smalltalk has objects, but a Smalltalk object’s methods and instance variables are distinct from the contents of a Smalltalk container like a dictionary or array. JavaScript’s objects are dictionaries, and an object’s methods and instance variables are the same thing as its contents.
    • Ruby has classes, modules, the metaclasses, and eigenclasses. JavaScript just has objects that are related to each other either with prototype chaining or as instance values.
    • When you invoke a method in Common Lisp, You may also be invoking multiple “before,” “after,” or “around” demons in addition to the method handler. In JavaScript, each method is handled by exactly one function.
    • Java’s methods cannot be added to or removed from classes once their bytecodes have been loaded. JavaScript’s methods can be added and removed at any time.

    These four “distinctions” between other languages and JavaScript are also the four pillars of object-oriented programming language semantics:

    • Objects are the things we use to encapsulate data and behaviour by exposing methods (and optionally properties).
    • Metaobjects like classes or prototypes are objects that define the behaviour of other objects.
    • Protocols are the rules by which we figure out what exactly happens when we send a message to an object.
    • Binding Times are the rules that determine when the behaviour of objects, metaobjects, and protocols can be added, removed, or changed.

    When we are truly “thinking in objects,” we are thinking in objects, thinking in metaobjects, and thinking in protocols. And for good measure, we are also thinking of when these things are “bound.” And that’s why JavaScript Spessore’s mission is to explore objects, metaobjects, protocols, and to examine the implications of when these behaviours are bound.

    J(oop)S

    You may be thinking to yourself, “This is all very well, but it sounds like it is about object-oriented programming in general and not really about the specifics in JavaScript. Why JavaScript? Why not Lisp or Smalltalk or OCaml or some other language with more powerful features?”

    The answer is that this is a book for programmers about thinking in objects, thinking that works in any OO language. It happens to be written in JavaScript instead of Lisp for the same reason that it happens to be written in English instead of Latin: Because it’s a language we share.

    Table of Contents

    • Prefaces
    • The Big Idea
    • JavaScript’s Objects
    • Object Recipes
    • Instances and Prototypes
    • Methods
    • Metaobjects
    • Encapsulation and Composition
    • Inheritance, Ontologies, and Semantic Types
    • Metaobject Protocols
    • Appendix: Source Code

    中文:

    书名:JavaScript厚度

    JavaScript Spessore推崇“在对象中思考”,从基础开始,在此基础上构建,然后探索思考面向对象编程的新方法。

    0,1,∞

    要真正在对象中思考,您必须将自己从任何一种语言的特性中解放出来,因为有不止一种方法可以“做”对象和面向对象编程。让我们将其他几种语言与JavaScript进行比较:

    • SmallTalk有对象,但SmallTalk对象的方法和实例变量与SmallTalk容器(如字典或数组)的内容不同。JavaScript的对象是字典,对象的方法和实例变量与其内容相同。
    • Ruby类有类、模块、元类和特征类。JavaScript只包含通过原型链接或作为实例值相互关联的对象。
    • 当您在Common Lisp中调用一个方法时,除了方法处理程序之外,您可能还调用了多个“之前”、“之后”或“周围”恶魔。在JavaScript中,每个方法只由一个函数处理。
    • 一旦加载了类的字节码,就不能在类中添加或删除Java的类方法。可以随时添加和删除JavaScript的方法。

    其他语言和Java脚本之间的这四个“区别”也是面向对象编程语言语义的四大支柱:

    • 对象是我们通过公开方法(以及可选的属性)来封装数据和行为的东西。
    • 元对象与类或原型一样,是定义其他对象行为的对象。
    • 协议是我们计算出当我们向对象发送消息时到底发生了什么的规则。
    • 绑定时间是确定何时可以添加、删除或更改对象、元对象和协议的行为的规则。

    当我们真正“在对象中思考”时,我们就是在对象中思考,在元对象中思考,在协议中思考。另外,我们也在考虑这些东西什么时候会被“捆绑”。这就是为什么JavaScript Spessore的使命是探索对象、元对象、协议,并检查这些行为何时被绑定的含义。

    J(OOP)S

    您可能会对自己说,“这一切都很好,但听起来它大体上是关于面向对象编程的,而不是真正关于JavaScript中的细节。为什么选择使用Java脚本?为什么不是Lisp、Smalltalk、OCaml或其他功能更强大的语言呢?

    答案是,这是一本面向程序员的书,讲述在对象中思考,在任何面向对象语言中工作的思考。它碰巧是用JavaScript而不是Lisp编写的,原因与它碰巧是用英语而不是拉丁语编写的原因相同:因为它是我们共享的语言。

    Table of Contents

    • 前言
    • The Big Idea
    • 的对象
    • Object Recipes
    • 实例和原型
    • 方法
    • Metaobjects
    • 封装和合成
    • 继承、本体和语义类型
    • Metaobject Protocols
    • 附录:源代码
  • 下载电子版:下载地址
  • 购买纸质版:亚马逊商城

    点击星号评分!

    平均分 0 / 5. 投票数: 0

    还没有投票!请为他投一票。

  • 推荐阅读

    评论 抢沙发

    评论前必须登录!

     

    登录

    找回密码

    注册