Skip to content

Commit 7a0ca71

Browse files
committed
better formatting
1 parent 822538a commit 7a0ca71

File tree

2 files changed

+111
-89
lines changed

2 files changed

+111
-89
lines changed

legacy-patterns.md

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
# 6. Code re-use patterns
1+
# Legacy patterns
22

3-
## classical inheritance
3+
Event though the book is amazing some patterns so the signs of aging (e.g. replaced by ES5 feautures or turned out to be bad ideas) Moved some of the older patterns here.
4+
5+
## 6. Code re-use patterns
6+
7+
### classical inheritance
48

59
* play on the word 'class', nothing to do with the word classical
610
* JavaScript has no classes but constructor functions make same people think that
@@ -16,7 +20,7 @@ inherit(Child, Parent);
1620

1721
* inherit is not part of the language have to implement it yourself
1822

19-
## classical default pattern
23+
### classical default pattern
2024

2125
```js
2226
function inherit(Child, Parent){
@@ -28,7 +32,7 @@ function inherit(Child, Parent){
2832
* drawback: children gets both own and prototype properties from parent
2933
* drawback: can't really pass parameters, or end up with a lot of objects
3034

31-
## classical rent-a-constructor pattern
35+
### classical rent-a-constructor pattern
3236

3337
```js
3438
function Child(a, b, c, d){
@@ -47,7 +51,7 @@ function Child(a, b, c, d){
4751
* multiple inheritance can be achieved by applying more than one constructors
4852
* in case of multiple inheritance and duplicate properties - last one wins
4953

50-
## classical rent-and-set prototype
54+
### classical rent-and-set prototype
5155

5256
```js
5357
function Child(a, b, c, d){
@@ -60,7 +64,7 @@ Child.prototype = new Parent();
6064
* and references re-usable functionality (from parents prototype)
6165
* drawback: parent constructor is called twice
6266

63-
## classical share the prototype pattern
67+
### classical share the prototype pattern
6468

6569
```js
6670
function inherit(Child, Parent){
@@ -72,7 +76,7 @@ function inherit(Child, Parent){
7276
* fast lookups as all object references one prototype
7377
* BUT children can modify parent behaviour
7478

75-
## classical temporary constructor pattern
79+
### classical temporary constructor pattern
7680

7781
```js
7882
function inherit(Child,Parent){
@@ -102,7 +106,7 @@ var inherit = (function(){
102106
})();
103107
```
104108

105-
## klass
109+
### klass
106110

107111
* some legacy JS libraries/frameworks emulate classes
108112
* usually there's a convention on how to name constructor functions (e.g. init)

0 commit comments

Comments
 (0)