forked from codex-academy/codeX_ProgrammingExercises
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslides.html
446 lines (275 loc) · 6.72 KB
/
slides.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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
<html>
<head>
<title>Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<style type="text/css">
@import url(http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(http://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(http://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
body { font-family: 'Droid Serif'; }
h1, h2, h3 {
font-family: 'Yanone Kaffeesatz';
font-weight: normal;
}
ul {
font-size: 32;
}
.remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; }
.inverse {
background: #272822;
color: #777872;
text-shadow: 0 0 20px #333;
}
.inverse h1, .inverse h2 {
color: #f3f3f3;
line-height: 0.8em;
}
ul {
}
</style>
</head>
<body>
<textarea id="source">
class: center, middle
# What is this programming thing all about?
@avermeulen
---
#Disclaimer
* My words
* Not an academic approach
* A way to get going
* Practice, practice
* Try things out
---
# What we will be doing
* What is a computer program?
* How does it work
* TDD
* Continuous Integration
* We will try it
---
# What is a computer program?
---
# What is a computer program?
* Takes input
* Process it
* Give some output
List of instructions that when executed, achieve a certain task.
How the instructions are triggered can vary…
---
# How does a computer program...
* remember stuff?
* know stuff?
* decide what to do?
* get stuff done?
* give feedback?
---
class: center, middle
#Computer Programs remember and know stuff using input stored in variables
---
# Variables
* Like buckets
## Like a labelled shelf
* The shelf is not the product?
* Different types
* Place holders of information
* Point to information
* Scope - what variables are visible when?
---
#Variables types
##Can be simple
Hold one variable : number/string/boolean
Variables can be objects - so we can ask them questions
* What is your length
* Give me a part of you - substring
## Complex
* Data structures
* Hold multiple values : List or Map
---
# Variables can hold behaviour and state -> knows what to do
* Object Orientation : behaviour and state
* Functional : Immutable state & behaviour can be passed around
## Persistence
Variables stored for later use
* Files
* Databases - SQL / NoSQL
* Localstorage - Javascript
---
# The journey of variables
---
# The journey of variables
* Variables are taken as input
* Variables are evaluated...
* Variables are given as output
---
#Computer programs get stuff done by applying logic on variables
---
#Computer programs get stuff done by applying logic on variables
* Variables are inspected
* Logic applied
* Arithmetic calculation
* Conditional statements
* Loops
* Task achieved…?
## ... can be synchronous or asynchronous
* Synchronous - one after the other
* Asynchronous - happens when it happens - no predictions
---
# Conditional statements
Do or don’t do something if a condition is true or false?
---
# Loops
* Do something or don’t do something until a condition is true or false?
* Blocking - don’t do anything until…
* Callback - do something when
---
# Function - Decisions/Logic grouped together
* Giving code a name
* It takes input
* May return output
---
class: center, middle
# How to do in Javascript?
---
#Variable declaration
```javascript
var username = “andre.vermeulen”;
var age = 38;
var jogger = true;
console.log(username);
console.log(age);
var today = Date.getDate();
// Functions / objects
// object literal
var person = {
username : “andre.vermeulen”,
age : 38,
birthDay : new Date(13, 1, 1976),
};
console.log(person.username);
var Person = function(username, age, birthDay) {
this.username = age;
this.age = age;
this.birthDay = birthDay;
};
var person = new Person(“andre.vermeulen”, 38, new Date(13, 1, 1976));
console.log(person.username);
```
---
# Logic
```javascript
if (person.birthDay === Date.getDate()){
person.age += 1;
}
```
# Loops :
```javascript
for(var i = 0; i < person.username.length; i++){
var letter = person.username[i];
if (letter !== “.”)
console.log(letter);
}
// using while
var counter = 0;
while(counter < person.username.length){
var letter = person.username[counter];
if (letter !== “.”)
console.log(letter);
counter = counter + 1;
}
```
---
#Functions in Javascript:
```javascript
var getLetters = function(thePerson){
var letters = [];
for(var i = 0; i < thePerson.username.length; i++){
var letter = thePerson.username[i];
if (letter !== “.”)
letters.push(letter)
}
return letters;
}
// calling a function
var lettersList = getLetters(person);
```
---
# Function scope
```javascript
var PersonFinder = function(){
// only visible in the function here
var names = [];
this.peopleNames = function(){
return names;
}
this.addPerson = function(person){
names.push(person);
}
};
// execute it like this...
var personFinder = new PersonFinder();
console.log(personFinder.peopleNames());
```
Don’t do this:
```javascript
var personFinder = PersonFinder();
```
this will be linked to the global scope…
---
# TDD
##Test Driven Development
* Way of testing what the program needs to do
* Test harness to execute logic written using a Unit Test
* Publish ones assumptions
## Test Harnesses:
* QUnit - xUnit => JUnit, NUnit etc
* Mocha - Javascript alternative
* Easy to see failing tests etc
---
# Continuous Integration
Allow a team to work together more effectively
Continuously integrating code into a central shared code repository
Unit tests for the program is executed whenever the central shared code repository changed.
## Using CI tool
* Check out the code
* Execute the tests
* Some test runner of sorts
* Gulp / Grunt
* Report failures
* Jenkins
* Travis
---
#Let’s give it ago!
https://github.com/codex-academy/codeX_ProgrammingExercises
---
#What is a computer program?
### How does a computer program
* remember stuff?
* know stuff?
* decide what to do?
* get stuff done?
* give feedback?
---
# What comes to mind?
---
# I hope...
* Variables
* Logic & Conditional Statement
* Loops
* Functions
* Doing all of that in Javascript
### TDD
### Continuous Integration
### We tried it out
---
class: center, middle
# Are you ready to go and try it?
---
</textarea>
<script src="http://gnab.github.io/remark/downloads/remark-latest.min.js" type="text/javascript">
</script>
<script type="text/javascript">
var slideshow = remark.create();
</script>
</body>
</html>