1+ < html >
2+ < head >
3+ < title > Title</ title >
4+ < meta http-equiv ="Content-Type " content ="text/html; charset=UTF-8 "/>
5+ < style type ="text/css ">
6+ @import url (http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
7+ @import url (http://fonts.googleapis.com/css?family=Droid+Serif:400, 700 , 400italic );
8+ @import url (http://fonts.googleapis.com/css?family=Ubuntu+Mono:400, 700 , 400italic );
9+
10+ body { font-family : 'Droid Serif' ; }
11+ h1 , h2 , h3 {
12+ font-family : 'Yanone Kaffeesatz' ;
13+ font-weight : normal;
14+ }
15+ .remark-code , .remark-inline-code { font-family : 'Ubuntu Mono' ; }
16+ </ style >
17+ </ head >
18+ < body >
19+ < textarea id ="source ">
20+
21+ class: center, middle
22+
23+ # Programming 101
24+
25+ @avermeulen
26+
27+ ---
28+
29+ # What we will be doing
30+
31+ * What is a computer program?
32+
33+ * How does it work
34+
35+ * TDD
36+
37+ * Continuous Integration
38+
39+ * We will try it
40+
41+ ---
42+
43+ # What is a computer program?
44+
45+ * Takes input
46+ * Process it
47+ * Give some output
48+
49+ List of instructions that when executed, achieve a certain task.
50+
51+ How the instructions are triggered can vary…
52+
53+ ---
54+
55+ # How does a computer program
56+
57+ … remember stuff?
58+
59+ … know stuff?
60+
61+ … decide what to do?
62+
63+ … get stuff done?
64+
65+ … give feedback?
66+
67+ ---
68+
69+ class: center, middle
70+
71+ #Computer Programs remember and know stuff using input stored in variables
72+
73+ ---
74+
75+
76+
77+ # Variables
78+ Like buckets
79+
80+ ## Like a shelve with labels on
81+ Different types
82+
83+ Place holders of information
84+
85+ Point to information
86+
87+ Scope - what variables are visible when?
88+
89+ ---
90+
91+ #Variables type
92+
93+ ##Can be simple
94+
95+ Hold one variable : number/string/boolean
96+
97+ Variables can be objects - so we can ask them questions
98+
99+ * What is your length
100+ * Give me a part of you - substring
101+
102+ ## Complex
103+ * Data structures
104+ * Hold multiple values : List or Map
105+
106+ ---
107+
108+ # Variables can hold behaviour and state -> knows what to do
109+ * Object Orientation : behaviour and state
110+ * Functional : Immutable state & behaviour can be passed around
111+
112+ ## Persistence
113+
114+ Variables stored for later use
115+ * Files
116+ * Databases - SQL / NoSQL
117+ * Localstorage - Javascript
118+
119+ ---
120+
121+ # The journey of variables
122+
123+ Variables are taken as input
124+
125+ Variables are evaluated...
126+
127+ Variables are given as output
128+
129+ ---
130+
131+ #Computer programs get stuff done by applying logic on variables
132+
133+ Variables are inspected
134+
135+ Logic applied
136+
137+ Arithmetic calculation
138+
139+ Conditional statements
140+
141+ Loops
142+
143+ Task achieved…?
144+
145+ ## ... can be synchronous or asynchronous
146+
147+ Synchronous - one after the other
148+
149+ Asynchronous - happens when it happens - no predictions
150+
151+ ---
152+
153+ # Conditional statements
154+
155+ Do or don’t do something if a condition is true or false?
156+
157+
158+ # Loops
159+
160+ Do something or don’t do something until a condition is true or false?
161+
162+ Block - don’t do anything until…
163+
164+ Callback - do something when
165+
166+ ---
167+
168+ # Function = Decisions/Logic grouped together
169+
170+ Give it a name
171+
172+ It takes input
173+
174+ May return output
175+
176+ ---
177+
178+ class: center, middle
179+
180+ # How to do in Javascript?
181+
182+ ---
183+
184+ #Variable declaration
185+
186+ ```javascript
187+
188+ var username = “andre.vermeulen”;
189+ var age = 38;
190+ var jogger = true;
191+
192+ console.log(username);
193+ console.log(age);
194+
195+ var today = Date.getDate();
196+
197+ // Functions / objects
198+ // object literal
199+
200+ var person = {
201+ username : “andre.vermeulen”,
202+ age : 38,
203+ birthDay : new Date(13, 1, 1976),
204+ };
205+
206+ console.log(person.username);
207+
208+ var Person = function(username, age, birthDay) {
209+ this.username = age;
210+ this.age = age;
211+ this.birthDay = birthDay;
212+ };
213+
214+ var person = new Person(“andre.vermeulen”, 38, new Date(13, 1, 1976));
215+ console.log(person.username);
216+
217+ ```
218+
219+ ---
220+
221+ # Logic
222+
223+ ```javascript
224+ if (person.birthDay === Date.getDate()){
225+ person.age += 1;
226+ }
227+ ```
228+
229+ # Loops :
230+
231+ ```javascript
232+
233+ for(var i = 0; i < person .username.length; i++){
234+ var letter = person.username[i];
235+ if (letter ! == “.”)
236+ console.log(letter);
237+ }
238+
239+ // using while
240+
241+ var counter = 0;
242+ while(counter < person .username.length){
243+ var letter = person.username[counter];
244+ if (letter ! == “.”)
245+ console.log(letter);
246+ counter = counter + 1;
247+ }
248+
249+
250+ ```
251+
252+ ---
253+
254+ #Functions in Javascript:
255+
256+ ```javascript
257+
258+ var getLetters = function(thePerson){
259+ var letters = [];
260+ for(var i = 0; i < thePerson .username.length; i++){
261+ var letter = thePerson.username[i];
262+ if (letter ! == “.”)
263+ letters.push(letter)
264+ }
265+ return letters;
266+ }
267+
268+ // calling a function
269+ var lettersList = getLetters(person);
270+
271+ ```
272+
273+ ---
274+
275+ # Function scope
276+
277+ ```javascript
278+
279+ var PersonFinder = function(){
280+ // only visible in the function here
281+ var names = [];
282+ this.peopleNames = function(){
283+ return names;
284+ }
285+
286+ this.addPerson = function(person){
287+ names.push(person);
288+ }
289+ };
290+
291+ // execute it like this...
292+ var personFinder = new PersonFinder();
293+
294+ console.log(personFinder.peopleNames());
295+
296+ ```
297+
298+ Don’t do this:
299+
300+ ```javascript
301+ var personFinder = PersonFinder();
302+ ```
303+
304+ this will be linked to the global scope…
305+
306+ ---
307+
308+ # TDD
309+
310+ ##Test Driven Development
311+
312+ Way of testing what the program needs to do
313+
314+ Test harness to execute logic written using a Unit Test
315+
316+ Publish ones assumptions
317+
318+ ## Test Harnesses:
319+ * QUnit - xUnit => JUnit, NUnit etc
320+ * Mocha - Javascript alternative
321+ * Easy to see failing tests etc
322+
323+ ---
324+
325+ # Continuous Integration
326+
327+ Allow a team to work together more effectively
328+
329+ Continuously integrating code into a central shared code repository
330+ Unit tests for the program is executed whenever the central shared code repository changed.
331+
332+ ## Using CI tool
333+ * Check out the code
334+ * Execute the tests
335+ * Some test runner of sorts
336+ * Gulp / Grunt
337+ * Report failures
338+ * Jenkins
339+ * Travis
340+
341+ ---
342+
343+ #Let’s give it ago!
344+
345+ https://github.com/codex-academy/codeX_ProgrammingExercises
346+
347+ ---
348+
349+ #What is a computer program?
350+
351+ ### How does a computer program
352+ remember stuff? // know stuff? //decide what to do? // get stuff done? //give feedback?
353+
354+ * Variables
355+ * Logic & Conditional Statement
356+ * Loops
357+ * Functions
358+
359+ * Doing all of that in Javascript
360+
361+ ### TDD
362+ ### Continuous Integration
363+ ### We tried it out
364+
365+ ---
366+
367+ class: center, middle
368+
369+ # Are you ready to go and try it?
370+
371+ ---
372+
373+ </ textarea >
374+ < script src ="http://gnab.github.io/remark/downloads/remark-latest.min.js " type ="text/javascript ">
375+ </ script >
376+ < script type ="text/javascript ">
377+ var slideshow = remark . create ( ) ;
378+ </ script >
379+ </ body >
380+ </ html >
0 commit comments