forked from debel/Web-Engineering-With-ES6-Presentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
276 lines (261 loc) · 9.54 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Web Engineering with ES6</title>
<link rel="stylesheet" href="bower_components/reveal-js/css/reveal.min.css"/>
<link rel="stylesheet" href="bower_components/reveal-js/css/theme/night.css"/>
<link rel="stylesheet" href="bower_components/reveal-js/lib/css/zenburn.css"/>
<style>
.es5>code{
border: 1px solid indianred;
}
.es6>code{
border: 1px solid mediumseagreen;
}
</style>
</head>
<body>
<div class="reveal">
<div class="slides">
<section id="title">
<h3>Mihail Mikov</h3>
<h2>Web Engineering with ES6</h2>
</section>
<section id="introduction">
<h3>Overview</h3>
- Readability
- Abstraction
- Quality
- Tools
- Vision
-
</section>
<section id="readability-quote">
<h3>Readability</h3>
<div class="fragment fade-in">
<div class="fragment fade-out">IFYOUWANTYOURCODETOBEEASYTOWRITEMAKEITEASYTOREAD</div>
</div>
<div class="fragment">If you want your code to be easy to write, make it easy to read.
<br/>
<div style="text-align: right;">--Uncle Bob</div>
</div>
</section>
<section id="readability-intro">
<h4>How does ES6 help readability?</h4>
<ul>
<li>Arrow functions</li>
<li>Classes</li>
<li>Object literals syntax</li>
<li>Destructing</li>
<li>Array spreading</li>
<li>Template strings</li>
</ul>
</section>
<section id="readability-arrows">
<h4>Arrow functions</h4>
<pre class="es5"><code class="javascript">
//es5
getNumbersAsync(function callback(a, b) {
return a + b;
});
</code></pre>
<pre class="es6"><code class="javascript">
//es6
getNumbersAsync((a, b) => a + b);
</code></pre>
</section>
<section id="readability-classes">
<h4>Classes</h4>
<pre class="es5"><code class="javascript">
//es5
function Car(model, color) {
this.model = model;
this.color = color;
}
Car.prototype.startEngine = function () {
return "Started the engine of the " + this.model;
};
</code></pre>
<pre class="es6"><code class="javascript">
//es6
class Car {
constructor(model, color) {
this.model = model;
this.color = color;
}
startEngine() {
return "Started the engine of the " + this.model;
}
}
</code></pre>
</section>
<section id="readability-objects">
<h4>Object literals syntax</h4>
<pre class="es5"><code class="javascript">
//es5
var name = 'Mihail',
myObject = {
name: name,
getFriends: function () { ... }
};
myObject[getPropertyName()] = 'some value';
</code></pre>
<pre class="es6"><code class="javascript">
//es6
let name = 'Mihail',
myObject = {
name,
getFriends() { ... },
[getPropertyName()]: 'some value'
};
</code></pre>
</section>
<section id="readability-destructing">
<h4>Destructing</h4>
<pre class="es5"><code class="javascript">
//es5
var coordinates = [23, 14],
x = coordinates[0],
y = coordinates[1];
var personalInfo = getPersonalInfo(),
name = personalInfo.name,
age = personalInfo.age,
petName = personalInfo.pet.name;
</code></pre>
<pre class="es6"><code class="javascript">
//es6
let [x, y] = [23, 14];
let { name, age, pet: { name: petName } } = getPersonalInfo();
</code></pre>
</section>
<section id="readability-spreading">
<h4>Array spreading</h4>
<pre class="es5"><code class="javascript">
//es5
function variableNumberOfArguments() {
//hack to get the arguments as an array
var args = Array.prototype.splice.call(arguments, 0);
}
var numbers = [1, 2, 3],
letters = ['a', 'b', 'c'],
both = numbers.concat(letters);
</code></pre>
<pre class="es6"><code class="javascript">
//es6
function variableNumberOfArguments(...args) {
//args is already an array with all arguments
}
let numbers = [1, 2, 3],
letters = ['a', 'b', 'c'],
both = [...numbers, ...letters];
</code></pre>
</section>
<section id="readability-strings">
<h4>Template strings</h4>
<pre class="es5"><code class="javascript">
//es5
"A " + car.color + " " + car.model + " just drove by"
</code></pre>
<pre class="es6"><code class="javascript">
//es6
`A ${car.color} ${car.model} just drove by`
</code></pre>
</section>
<section id="abstraction-quote">
<h3>Abstraction</h3>
<div class="fragment">The art of programming is the art of organizing complexity
<br/><div style="text-align: right">--Edsger Dijkstra</div></div>
</section>
<section id="abstraction-intro">
<h4>How does ES6 help abstraction?</h4>
<ul>
<li>Sets & Maps</li>
<li>Generators</li>
<li>Promises</li>
</ul>
</section>
<section id="abstraction-maps">
<h4>Sets & Maps</h4>
<pre class="es6"><code class="javascript">
//Sets
var key = 'any type of value',
set = new Set();
set.add(key);
set.has(key) //returns true or false
</code></pre>
<pre class="es6"><code class="javascript">
//Maps
var key = { a: 1 },
value = { b: 2 },
map = new Map();
map.set(key, value);
map.get(key) //returns value
</code></pre>
</section>
<section id="abstraction-generators">
<h4>Generators</h4>
<pre class="es6"><code class="javascript">
function* squaresMaker() {
let i = 1;
while (true) {
yield i*i;
i += 1;
}
};
let squares = squaresMaker();
squares.next(); // { value: 1, done: false }
squares.next(); // { value: 4, done: false }
squares.next(); // { value: 9, done: false }
squares.next(); // { value: 16, done: false }
</code></pre>
</section>
<section id="abstraction-promises">
<h4>Promises</h4>
<pre class="es6"><code class="javascript">
//how to use promises
getNumbersAsync()
.then((a,b) => a + b)
.then(sendSumToServer)
.catch(logError);
//how to create a promise
let after10Seconds = new Promise((y, n) => {
setTimeout(y, 10000);
});
//promise helper methods
Promise.resolve(value)
Promise.reject(error)
Promise.all([array, of, promises])
Promise.race([array, of, promises])
</code></pre>
</section>
<section>
Quality
</section>
<section>
Tools
</section>
<section>
Vision
</section>
</div>
</div>
<script src="bower_components/reveal-js/lib/js/head.min.js"></script>
<script src="bower_components/reveal-js/js/reveal.min.js"></script>
<script>
Reveal.initialize({
transition: 'fade',
transitionSpeed: 'fast',
controls: false,
history: true,
slideNumber: 'c/t',
dependencies: [
{
src: 'bower_components/reveal-js/plugin/highlight/highlight.js',
callback: function () { hljs.initHighlightingOnLoad(); }
}
]
});
</script>
</body>
</html>