don't leave windows broken

61
Don’t Leave Windows Broken Kenju Wagatsuma

Upload: ken-william

Post on 16-Apr-2017

439 views

Category:

Software


1 download

TRANSCRIPT

Page 1: Don't Leave Windows Broken

Don’t Leave Windows Broken

Kenju Wagatsuma

Page 2: Don't Leave Windows Broken

Agenda: ->

❖ 1m : Self Introduction ❖ 5m : 0. Goal & Outline ❖ 8m : 1. Linting ❖ 8m : 2. Unit Testing ❖ 8m : 3. Know JavaScript Bad Parts

Page 3: Don't Leave Windows Broken

/** * Introduce Myself * * @kenju */

Page 4: Don't Leave Windows Broken

“me” = { “name” : “Kenju Wagatsuma ( KJ )”,

}

Page 5: Don't Leave Windows Broken

“me” = { “name” : “Kenju Wagatsuma ( KJ )”, “company” : “Recruit Technologies Co.,LTD.”,

}

Page 6: Don't Leave Windows Broken

“me” = { “name” : “Kenju Wagatsuma ( KJ )”, “company” : “Recruit Technologies Co.,LTD.”, “profession” : “Android Development”,

}

Page 7: Don't Leave Windows Broken

“me” = { “name” : “Kenju Wagatsuma ( KJ )”, “company” : “Recruit Technologies Co.,LTD.”, “profession” : “Android Development”, “favs” : { 'Music' : ‘Stevie Wonder', 'Hobby' : ‘Acoustic Guitar & Singing’, 'Sport' : 'Rugby' } }

Page 8: Don't Leave Windows Broken

/** * 0. Goal & Outline * * @author me */

Page 9: Don't Leave Windows Broken

Goal

Don’t Leave Windows Broken

Page 10: Don't Leave Windows Broken
Page 11: Don't Leave Windows Broken

#2 “Software Entropy”

One broken window, left unrepaired for any substantial length of time, instills in the inhabitants of the building a sense of abandonment - a sense that the powers that be don’t care about the building.

Page 12: Don't Leave Windows Broken

Quiz

Refactor This Code

Page 13: Don't Leave Windows Broken

Bad Sample

Page 14: Don't Leave Windows Broken

Bad Sample : Answer

Page 15: Don't Leave Windows Broken

This is the Broken Windows

Page 16: Don't Leave Windows Broken

How to avoid?

❖ Linting ❖ ❖

Page 17: Don't Leave Windows Broken

How to avoid?

❖ Linting ❖ Unit Testing ❖

Page 18: Don't Leave Windows Broken

How to avoid?

❖ Linting ❖ Unit Testing ❖ Understand The Bad Parts of JavaScript

Page 19: Don't Leave Windows Broken

/** * 1. Linting * * @author me */

Page 20: Don't Leave Windows Broken

What is Lint?

❖ Generically, lint or a linter is any tool that flags suspicious usage in software written in any computer language

Page 21: Don't Leave Windows Broken

ESLint

Page 22: Don't Leave Windows Broken

What is ESLint?

❖ is an open source JavaScript linting utility ❖ ❖

Page 23: Don't Leave Windows Broken

What is ESLint?

❖ is an open source JavaScript linting utility ❖ is written using Node.js ❖

Page 24: Don't Leave Windows Broken

What is ESLint?

❖ is an open source JavaScript linting utility ❖ is written using Node.js ❖ and easy installation via npm

Page 25: Don't Leave Windows Broken

How to ESLint?

Page 26: Don't Leave Windows Broken

How to ESLint?

Page 27: Don't Leave Windows Broken

Why is ESLint?

❖ JavaScript is loosely-typed so that is prone to developer error

❖ ❖

Page 28: Don't Leave Windows Broken

Why is ESLint?

❖ JavaScript is loosely-typed so that is prone to developer error

❖ JavaScript has no compilation ❖

Page 29: Don't Leave Windows Broken

Why is ESLint?

❖ JavaScript is loosely-typed so that is prone to developer error

❖ JavaScript has no compilation ❖ ESLint discovers problems with their

JavaScript code without executing it

Page 30: Don't Leave Windows Broken

Live Coding Linting

Page 31: Don't Leave Windows Broken

/** * 2. Unit Testing * * @author me */

Page 32: Don't Leave Windows Broken

What is Unit Test?

❖ Testing done on each module ( function, methods, etc. ) in isolation, to verify its behaviour

Page 33: Don't Leave Windows Broken

Why Unit Test?❖ 1. Examples of how to use all

the functionality of your module

❖ 2. A means to build regression tests to validate any future changes to the code

Page 34: Don't Leave Windows Broken

What is Karma?❖ is testing development ❖ is not a testing framework,

nor an assertion library ❖ (on which Jasmine, QUnit or

other testing frameworks run)

Page 35: Don't Leave Windows Broken

❖ is an open source testing framework for JavaScript

❖ runs on any JavaScript-enabled platform

❖ does not require a DOM

What is Jasmine?

Page 36: Don't Leave Windows Broken

Unit Testing

Karma

Jasmine

Web Browser

Write Unit Testing

Execute Unit Testing

Where Unit TestingRuns On

Page 37: Don't Leave Windows Broken

0. Install Karma/Jasmine# Install Jasmine $ npm install -g jasmine

# Install Karma $ npm install -g karma-cli

Page 38: Don't Leave Windows Broken

1. Initialise Directory# Initialise $ karma init

Which testing framework do you want to use ? Press tab to list possible options. Enter to

move to the next question. > jasmine

… … …

Page 39: Don't Leave Windows Broken

1. Initialise Directory. ├── karma.conf.js (config file) ├── spec │   └── MainAppSpec.js (Test) └── src └── MainApp.js (Main File)

Page 40: Don't Leave Windows Broken

2. Set configure file(karma.conf.js) … … files: [ 'spec/*.js', 'src/*.js' ], … …

Page 41: Don't Leave Windows Broken

3. Write Test First(./spec/MainAppSpec.js)

describe("CalculationUtil Test", function() {

// CalculationUtil.sum() it("100 plus 300 is 400", function() { expect(CalculationUtil.sum(100, 300)).toBe(400); });

// CalculationUtil.multiply() it("300 multiply 3 is 900", function() { expect(CalculationUtil.multiply(300, 3)).toBe(900); });

});

Page 42: Don't Leave Windows Broken

4. Write Program(./src/MainApp.js)

var CalculationUtil = CalculationUtil || {};

CalculationUtil.sum = function(x, y) { if (typeof x !== 'number' || typeof y !== 'number') return; return x + y; };

CalculationUtil.multiply = function(x, y) { if (typeof x !== 'number' || typeof y !== 'number') return; return x * y; }

Page 43: Don't Leave Windows Broken

5. Run Karma# Run Karma $ karma start karma.conf.js

… … (Test Result would show here)

Page 44: Don't Leave Windows Broken

Live Coding Testing

Page 45: Don't Leave Windows Broken

/** * 3. JavaScript : * The Bad Parts * * @author me */

Page 46: Don't Leave Windows Broken

Read This.

Page 47: Don't Leave Windows Broken

1. ==‘’ == ‘0’ // false 0 == ‘’ // true 0 == ‘0’ // true

false == ‘false’ // false false == ‘0’ // true

false == undefined // false false == null // false null == undefined // true

Page 48: Don't Leave Windows Broken

2. forgotten ‘var’

Page 49: Don't Leave Windows Broken

3. Reserved Words

Page 50: Don't Leave Windows Broken

And Much More.

Page 51: Don't Leave Windows Broken

/** * Happy Coding! * */

Page 52: Don't Leave Windows Broken

/** * Appendix * */

Page 53: Don't Leave Windows Broken

Blog

“The Art of Debugging”

@see https://remysharp.com/2015/10/14/the-art-of-debugging

Page 54: Don't Leave Windows Broken

Blog

“朝Lint活動で細かな技術的負債を返済する”

@see http://techlife.cookpad.com/entry/2015/09/15/190000

Page 55: Don't Leave Windows Broken

Blog

“karmaを使ったテスト駆動開発入門(ついでにJasmineも)”

@see http://qiita.com/shinofara/items/b3677ffdfc0c7e45e8d4 

Page 56: Don't Leave Windows Broken

Discussion

“JavaScript unit test tools for TDD”

@see http://stackoverflow.com/questions/300855/javascript-unit-test-tools-for-tdd

Page 57: Don't Leave Windows Broken

Documentation

“Getting Started with ESLint”

@see http://eslint.org/docs/user-guide/getting-started

Page 58: Don't Leave Windows Broken

Documentation

“Jasmine - introduction.js”

@see http://jasmine.github.io/2.4/introduction.html

Page 59: Don't Leave Windows Broken

Book

“JavaScript : The Good Parts”

@see http://bdcampbell.net/javascript/book/javascript_the_good_parts.pdf

Page 60: Don't Leave Windows Broken

/** * Contacts * */

Page 61: Don't Leave Windows Broken

“contact” = {

“Twitter” : “@kenjuwagatsuma”,

“GitHub” : “https://github.com/KENJU”,

“Blog” : “https://medium.com/@kenjuwagatsuma”

}