Day1 - TDD (Lecture SS 2015)
-
Upload
wolframkriesing -
Category
Technology
-
view
64 -
download
0
Transcript of Day1 - TDD (Lecture SS 2015)
� � !!
����� � � �� !"leanpub.com/socra"!
TDD + JavaScript
From „wtf“ to „hell yeah“
Wolfram Kriesing, uxebu @wolframkriesing
My slides are english
Refaktorisierung
Einheitentest
Akzeptanztest
Paar-Programmierung
How I wish to be programming …
Still learning not to …
Sche
dule
Intro No Ping Pong TDDing Baby steps GSpread
break
we hack
What is (Software) Craftsmanship?
Journey
endless journey
https://leanpub.com/socra
Hello
Something about me …
About you …
JavaScript - Var(ious) #1
http://dmitry.baranovskiy.com/post/91403200
JavaScript - Var(ious) #2
JavaScript - Var(ious) #2.1
JavaScript - Var(ious) #3
JavaScript - Var(ious) #4
Let’s hack
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
Did you get it done?
Do you like your code?
Do you know it works?
Did you have a strategy?
Did you write on paper?
Let’s say you have to add a feature.Will all the rest still work?
Is your code maintainable?
What is TDD?
TDD is no Replacement for
OO Design (Patterns)SOLIDDRY
but helps detect deficiencies
Law of Demeter
aim of TDD: help to get
a good design side effect: unit tests
Step by Step
Step 1
Find a deficiencywrite it out in code, in a test
• focus • constrain the problem
Step 2
Design (the API)because test code uses it
• we get feedback • we understand testability
„TDD is no better than it’s driver“
http://www.davesquared.net/2011/03/why-learning-tdd-is-hard-and-what-to-do.html
Quick feedback
Se
ssio
n #
2
Code Kata
Code Kata
first mentionedby Dave Thomas
(co-author of the book The Pragmatic Programmer)
Code Kata
to improve your programming skills
by challenging your abilities
and encouraging you to find multiple approaches
is a small exercise
Coding Dojo
•First Coding Dojo in France
•Practice - like a musician
•TDD
•Pair Programming
•Safe Environment
•No deadlines
•Improve your skills
CodeRetreat
CodeRetreat
5x
one day long
intensive exchange
CodeRetreat
coderetreat.org
JS CodeRetreat
jscoderetreat.com
TDD #1
Choose a pair!Someone you never worked with!
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
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
Throw away your code At least don’t use it in session #2
Retro #1
Where is TDD?
Cost, Time, Effort
Functional Tests Integration Tests Exploratory Tests
Manual Tests …
Unit Tests
TDD #2
Choose a new pair!
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!
Roman numerals
1 I
5 V
10 X
50 L
100 C
500 D
1000 M
• Implement 1..?• 45 minutes• no estimate• GO
Retro #2
What is TDD?
Kent Beck rediscovered TDD in 2003
encourages simple designs
Beck, K. Test-Driven Development by Example, Addison Wesley - Vaseem, 2003
inspires confidence
confidence
confidencesimple design
Helps Design
Easy to Test? Simple Design?
What is a unit test?
Testability
What is a unit?
Tennis Session #1 AAA
http://blog.mikemccandless.com/2014/08/scoring-tennis-using-finite-state.html
love all
while true; do npm test; sleep 3; done;
Tennis Session #2 4 rules of simple design
4 rules of simple design
http://c2.com/cgi/wiki?XpSimplicityRules
1) pass all tests
4 rules of simple design
http://c2.com/cgi/wiki?XpSimplicityRules
1) pass all tests
2) clear, expressive and consistent
4 rules of simple design
http://c2.com/cgi/wiki?XpSimplicityRules
1) pass all tests
2) clear, expressive and consistent
3) no duplication
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
GO!
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
I wrote too much code last time.
I SHOULD STOP DOING THAT!
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
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