- The Node Craftsman Book
- Manuel Kiessling
- 227字
- 2021-07-02 23:36:52
Blueprints versus finger-pointing
Let's start by looking at how typical object-oriented languages actually create objects.
We are going to talk about an object called myCar. The myCar object is our bits-and-bytes representation of an incredibly simplified real world car. It could have attributes like color and weight, and methods like drive and honk.
In a real application, myCar could be used to represent the car in a racing game – but we are going to completely ignore the context of this object, because we will talk about the nature and usage of this object in a more abstract way.
If you would want to use this myCar object in, say, Java, you need to define the blueprint of this specific object first – this is what Java and most other object-oriented languages call a class.
If you want to create the object myCar, you tell Java to build a new object after the specification that is laid out in the class Car.
The newly built object shares certain aspects with its blueprint. If you call the method honk on your object, like so:
myCar.honk();
Then the Java VM will go to the class of myCar and look up which code it actually needs to execute, which is defined in the honk method of class Car.
Ok, nothing shockingly new here. Enter JavaScript.
- Getting Started with oVirt 3.3
- Linux操作系統(tǒng)基礎(chǔ)
- 嵌入式操作系統(tǒng)(Linux篇)(微課版)
- 網(wǎng)絡(luò)操作系統(tǒng)管理與應(yīng)用(第三版)
- 從實(shí)踐中學(xué)習(xí)Kali Linux無(wú)線網(wǎng)絡(luò)滲透測(cè)試
- 計(jì)算機(jī)應(yīng)用基礎(chǔ)(Windows 7+Office 2016)
- Red Hat Enterprise Linux 6.4網(wǎng)絡(luò)操作系統(tǒng)詳解
- Learn CUDA Programming
- Learn OpenShift
- 電腦辦公(Windows10+Office2016)從新手到高手
- 程序員必讀經(jīng)典(算法基礎(chǔ)+計(jì)算機(jī)系統(tǒng))
- Docker for Developers
- Windows PE權(quán)威指南
- SQL Server on Azure Virtual Machines
- 深入理解嵌入式Linux設(shè)備驅(qū)動(dòng)程序