day1 - tdd (lecture ss 2015)

94
"leanpub.com/socra"

Upload: wolframkriesing

Post on 17-Jul-2015

64 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Day1 - TDD (Lecture SS 2015)

� � !!

����� � � �� !"leanpub.com/socra"!

Page 2: Day1 - TDD (Lecture SS 2015)

TDD + JavaScript

From „wtf“ to „hell yeah“

Wolfram Kriesing, uxebu @wolframkriesing

Page 3: Day1 - TDD (Lecture SS 2015)

My slides are english

Refaktorisierung

Einheitentest

Akzeptanztest

Paar-Programmierung

Page 4: Day1 - TDD (Lecture SS 2015)

How I wish to be programming …

Page 5: Day1 - TDD (Lecture SS 2015)
Page 6: Day1 - TDD (Lecture SS 2015)

Still learning not to …

Page 7: Day1 - TDD (Lecture SS 2015)
Page 8: Day1 - TDD (Lecture SS 2015)

Sche

dule

Intro No Ping Pong TDDing Baby steps GSpread

break

we hack

Page 9: Day1 - TDD (Lecture SS 2015)

What is (Software) Craftsmanship?

Page 10: Day1 - TDD (Lecture SS 2015)

Journey

Page 11: Day1 - TDD (Lecture SS 2015)

endless journey

Page 12: Day1 - TDD (Lecture SS 2015)

https://leanpub.com/socra

Page 13: Day1 - TDD (Lecture SS 2015)
Page 14: Day1 - TDD (Lecture SS 2015)

Hello

Page 15: Day1 - TDD (Lecture SS 2015)

Something about me …

Page 16: Day1 - TDD (Lecture SS 2015)

About you …

Page 17: Day1 - TDD (Lecture SS 2015)

JavaScript - Var(ious) #1

http://dmitry.baranovskiy.com/post/91403200

Page 18: Day1 - TDD (Lecture SS 2015)

JavaScript - Var(ious) #2

Page 19: Day1 - TDD (Lecture SS 2015)

JavaScript - Var(ious) #2.1

Page 20: Day1 - TDD (Lecture SS 2015)

JavaScript - Var(ious) #3

Page 21: Day1 - TDD (Lecture SS 2015)

JavaScript - Var(ious) #4

Page 22: Day1 - TDD (Lecture SS 2015)

Let’s hack

Page 23: Day1 - TDD (Lecture SS 2015)

Roman numerals

1 I

5 V

10 X

50 L

100 C

500 D

1000 M

• build as much as you can• 30min• estimate if you get it done• GO

IV - 4IX - 9

XII - 12XIX - 19XLIX - 49

Page 24: Day1 - TDD (Lecture SS 2015)
Page 25: Day1 - TDD (Lecture SS 2015)

Did you get it done?

Page 26: Day1 - TDD (Lecture SS 2015)
Page 27: Day1 - TDD (Lecture SS 2015)

Do you like your code?

Page 28: Day1 - TDD (Lecture SS 2015)

Do you know it works?

Page 29: Day1 - TDD (Lecture SS 2015)
Page 30: Day1 - TDD (Lecture SS 2015)
Page 31: Day1 - TDD (Lecture SS 2015)

Did you have a strategy?

Page 32: Day1 - TDD (Lecture SS 2015)

Did you write on paper?

Page 33: Day1 - TDD (Lecture SS 2015)

Let’s say you have to add a feature.Will all the rest still work?

Page 34: Day1 - TDD (Lecture SS 2015)

Is your code maintainable?

Page 35: Day1 - TDD (Lecture SS 2015)

What is TDD?

Page 36: Day1 - TDD (Lecture SS 2015)

TDD is no Replacement for

OO Design (Patterns)SOLIDDRY

but helps detect deficiencies

Law of Demeter

Page 37: Day1 - TDD (Lecture SS 2015)
Page 38: Day1 - TDD (Lecture SS 2015)

aim of TDD: help to get

a good design side effect: unit tests

Page 39: Day1 - TDD (Lecture SS 2015)

Step by Step

Page 40: Day1 - TDD (Lecture SS 2015)

Step 1

Find a deficiencywrite it out in code, in a test

• focus • constrain the problem

Page 41: Day1 - TDD (Lecture SS 2015)

Step 2

Design (the API)because test code uses it

• we get feedback • we understand testability

Page 42: Day1 - TDD (Lecture SS 2015)
Page 43: Day1 - TDD (Lecture SS 2015)

„TDD is no better than it’s driver“

http://www.davesquared.net/2011/03/why-learning-tdd-is-hard-and-what-to-do.html

Page 44: Day1 - TDD (Lecture SS 2015)

Quick feedback

Page 45: Day1 - TDD (Lecture SS 2015)

Se

ssio

n #

2

Page 46: Day1 - TDD (Lecture SS 2015)

Code Kata

Page 47: Day1 - TDD (Lecture SS 2015)
Page 48: Day1 - TDD (Lecture SS 2015)

Code Kata

first mentionedby Dave Thomas

(co-author of the book The Pragmatic Programmer)

Page 49: Day1 - TDD (Lecture SS 2015)

Code Kata

to improve your programming skills

by challenging your abilities

and encouraging you to find multiple approaches

is a small exercise

Page 50: Day1 - TDD (Lecture SS 2015)

Coding Dojo

Page 51: Day1 - TDD (Lecture SS 2015)

•First Coding Dojo in France

•Practice - like a musician

•TDD

•Pair Programming

•Safe Environment

•No deadlines

•Improve your skills

Page 52: Day1 - TDD (Lecture SS 2015)

CodeRetreat

Page 53: Day1 - TDD (Lecture SS 2015)

CodeRetreat

5x

one day long

intensive exchange

Page 54: Day1 - TDD (Lecture SS 2015)

CodeRetreat

coderetreat.org

Page 55: Day1 - TDD (Lecture SS 2015)

JS CodeRetreat

jscoderetreat.com

Page 56: Day1 - TDD (Lecture SS 2015)

TDD #1

Page 57: Day1 - TDD (Lecture SS 2015)
Page 58: Day1 - TDD (Lecture SS 2015)

Choose a pair!Someone you never worked with!

Page 59: Day1 - TDD (Lecture SS 2015)

Basic rules

• One types, the other tells what to type

• Write a failing test first

• Do as little as possible to make it green

• Switch roles on green

Page 60: Day1 - TDD (Lecture SS 2015)

Roman numerals

1 I

5 V

10 X

50 L

100 C

500 D

1000 M

• Implement 1..?• you got 45 minutes• no estimate• GO

Page 61: Day1 - TDD (Lecture SS 2015)

Throw away your code At least don’t use it in session #2

Page 62: Day1 - TDD (Lecture SS 2015)

Retro #1

Page 63: Day1 - TDD (Lecture SS 2015)

Where is TDD?

Page 64: Day1 - TDD (Lecture SS 2015)

Cost, Time, Effort

Page 65: Day1 - TDD (Lecture SS 2015)

Functional Tests Integration Tests Exploratory Tests

Manual Tests …

Unit Tests

Page 66: Day1 - TDD (Lecture SS 2015)

TDD #2

Page 67: Day1 - TDD (Lecture SS 2015)

Choose a new pair!

Page 68: Day1 - TDD (Lecture SS 2015)

Basic rules

• One types, the other tells what to type

• Write a failing test first

• Do as little as possible to make it green

• Switch roles on green

• Improve over last time!

Page 69: Day1 - TDD (Lecture SS 2015)

Roman numerals

1 I

5 V

10 X

50 L

100 C

500 D

1000 M

• Implement 1..?• 45 minutes• no estimate• GO

Page 70: Day1 - TDD (Lecture SS 2015)

Retro #2

Page 71: Day1 - TDD (Lecture SS 2015)

What is TDD?

Page 72: Day1 - TDD (Lecture SS 2015)

Kent Beck rediscovered TDD in 2003

Page 73: Day1 - TDD (Lecture SS 2015)

encourages simple designs

Beck, K. Test-Driven Development by Example, Addison Wesley - Vaseem, 2003

inspires confidence

Page 74: Day1 - TDD (Lecture SS 2015)

confidence

Page 75: Day1 - TDD (Lecture SS 2015)

confidencesimple design

Page 76: Day1 - TDD (Lecture SS 2015)
Page 77: Day1 - TDD (Lecture SS 2015)

Helps Design

Page 78: Day1 - TDD (Lecture SS 2015)

Easy to Test? Simple Design?

Page 79: Day1 - TDD (Lecture SS 2015)
Page 80: Day1 - TDD (Lecture SS 2015)

What is a unit test?

Testability

What is a unit?

Page 81: Day1 - TDD (Lecture SS 2015)

Tennis Session #1 AAA

Page 82: Day1 - TDD (Lecture SS 2015)
Page 83: Day1 - TDD (Lecture SS 2015)
Page 84: Day1 - TDD (Lecture SS 2015)

http://blog.mikemccandless.com/2014/08/scoring-tennis-using-finite-state.html

love all

while true; do npm test; sleep 3; done;

Page 85: Day1 - TDD (Lecture SS 2015)

Tennis Session #2 4 rules of simple design

Page 86: Day1 - TDD (Lecture SS 2015)

4 rules of simple design

http://c2.com/cgi/wiki?XpSimplicityRules

1) pass all tests

Page 87: Day1 - TDD (Lecture SS 2015)

4 rules of simple design

http://c2.com/cgi/wiki?XpSimplicityRules

1) pass all tests

2) clear, expressive and consistent

Page 88: Day1 - TDD (Lecture SS 2015)

4 rules of simple design

http://c2.com/cgi/wiki?XpSimplicityRules

1) pass all tests

2) clear, expressive and consistent

3) no duplication

Page 89: Day1 - TDD (Lecture SS 2015)

4 rules of simple design

http://c2.com/cgi/wiki?XpSimplicityRules

1) pass all tests

2) clear, expressive and consistent

3) no duplication

4) small and simple code

Page 90: Day1 - TDD (Lecture SS 2015)

GO!

Page 91: Day1 - TDD (Lecture SS 2015)

Step 1 - Think

Step 2 - Write a test

Step 3 - How much does this test suck?

Step 4 - Run the test and watch it fail

Step 5 - Write just enough code to make it pass

Page 92: Day1 - TDD (Lecture SS 2015)

I wrote too much code last time.

I SHOULD STOP DOING THAT!

Page 93: Day1 - TDD (Lecture SS 2015)

Step 1 - Think

Step 2 - Write a test

Step 3 - How much does this test suck?

Step 4 - Run the test and watch it fail

Step 5 - Write just enough code to make it pass

Page 94: Day1 - TDD (Lecture SS 2015)

TDD - J.B. Rainsberger

Step 1 - Think

Step 2 - Write a test

Step 3 - How much does this test suck?

Step 4 - Run the test and watch it fail

Step 5 - Write just enough code to make it pass