- Min @ongmin
- Instances inherit from a blueprint (the class).
- Create sub-class relationships.
- First create an instance and then invoke methods on that instance.
- JavaScript does not have classes, but we can program as though it does.
-> Hello ES6 classes
- Instances inherit from other instances.
- Objects Linking to Other Objects (OLOO)
- Using concatenative inheritance, you just copy properties from an exemplar object to a new instance.
Syntactical sugar over the Objects and prototypes that we're used to working with.
Simply a clean way to create objects and deal with inheritance.
Beauty in extend. (not here
Expects two parameters:
name and year.
Creates an instance of Book and assigns the params to a variable.
Here:
-Relationships and delegation are identical.
-The memory usage is identical.
-The ability to create many "kids" is identical.
OLOO relies on Object.create() to create a new object which is [[prototype]]-linked to another object.
Almost everything in JavaScript is an object..
Objects contain named properties
- obj.propName || obj['propName']
Each object has an internal property called prototype, which links to another object.
The prototype object has a prototype object of its own, and so on – aka the prototype chain.
It doesn't go on forever...
If you follow an object’s prototype chain, you will eventually reach the core Object prototype whose prototype is null. This signals the end of the chain.
The coupling between a child class and its parent is the tightest form of coupling in OO design. That’s the opposite of reusable, modular code.
Making small changes to a class creates rippling side-effects that break things that should be completely unrelated.
http://wildlyinaccurate.com/understanding-javascript-inheritance-and-the-prototype-chain/
https://medium.com/javascript-scene/the-two-pillars-of-javascript-ee6f3281e7f3
http://www.crockford.com/javascript/inheritance.html
http://www.udemy.com
http://stackoverflow.com/questions/29788181/kyle-simpsons-oloo-pattern-vs-prototype-design-pattern
Classical Inheritance
Swiss Inheritance
Parasitic Inheritance
Class Augmentation
Object Augmentation.