The slides of the Global Day of Coderetreat Munich 2018 I facilitated and we organized in the context of our Software Craft Meetup Munich on 17.11.2018.
26. HOW IS YOUR EXPERIENCE
LEVEL WITH TDD?
PLEASE LINE UP!
27. KATA
TIC TAC TOE
3x3 Board
Player "X" and "O"
Player with 3 in one line wins
• horizontal
• vertical
• diagonal
28. SESSION 1 PART 1
"THE TEST LIST"
Goal
Understand
• the problem
• its test cases
29. SESSION 1 PART 1
"THE TEST LIST"
Think about the use cases / user stories
What are reasonable boundaries?
Collect a list of tests in a text file (no code!)
30. SESSION 1 PART 1
"THE TEST LIST"
Sync
What features / boundaries did you find?
What tests did you find?
Test categories? Dimensions?
31. SESSION 1 PART 2
"TEST FIRST"
Write a test and let it fail
Write the simplest possible
implementation that the test runs green
32. SESSION 1 PART 2
"TEST FIRST"
Why?
Set a clear goal
no YAGNI
Separate API from Implementation
Causality: Red->Green
Testing discipline, high coverage
early ROI
Only chance for testing an error message
33. SESSION 1 PART 2
"TEST FIRST"
Write one test
Let them fail
Make the test failure expressive
Continue with next very different test
34. SESSION 1 PART 2
"TEST FIRST"
Sync
Which tests did you write?
Are your test failures expressive?
Object(s) under Test?
37. SESSION 2
"TDD + PING PONG"
Focus
write test: what should code do
implement: solve the problem
refactor: good design
38. SESSION 2
"TDD + PING PONG"
1. Passes all Tests
2. Reveals intention
3. No Duplication
4. Fewer Elements
4 Rules of Simple Design
39. SESSION 2
"TDD + PING PONG"
Uncle Bob’s 3 Rules of TDD
1. You can't write any production code until you
have first written a failing unit test.
2. You can't write more of a unit test than is
sufficient to fail, and not compiling is failing.
3. You can't write more production code than is
sufficient to pass the currently failing unit test.
41. SESSION 2
"TDD + PING PONG"
Ping Pong Pairing
1. Alice writes failing test
2. Bob makes test green
3. Bob writes failing test
4. Alice makes test green
5. Alice writes failing test
6. …
42. SESSION 2
"TDD + PING PONG"
Uncle Bob’s 3 Rules of TDD
1. You can't write any production code until you
have first written a failing unit test.
2. You can't write more of a unit test than is
sufficient to fail, and not compiling is failing.
3. You can't write more production code than is
sufficient to pass the currently failing unit test.
Do refactor duplication and improve names
43. SESSION 2
"TDD + PING PONG"
Sync
What did you observe?
What did (not) work?
What about design/refactoring?
How did pairing work?
44. SESSION 3
"BABY STEPS TDD"
LEARNING GOALS
Why are baby steps important
How to achieve baby steps
45. SESSION 3
"BABY STEPS TDD"
change 1
Initial code state
change 2
state 1
state 2
…
change n
target code state
● slow feedback
● high risk
● exponential complexity
● problems hard to find
LEAP
46. SESSION 3
"BABY STEPS TDD"
get green asap
● commit on green
● revert to green
change 1
Initial state
change 2
state 1
state 2
…
change n
target state
BABY STEPS
47. SESSION 3
"BABY STEPS TDD"
+ fast feedback
+ less risk
- a bit more effort
change 1
Initial state
change 2
state 1
state 2
…
change n
target state
BABY STEPS
48. SESSION 3
"BABY STEPS TDD"
Start a 2 min. timer when you get red
When back to green reset the timer and
When timer rings and you are still in red
git reset --hard
git commit
49. SESSION 3
"BABY STEPS TDD"
Sync
How did it work, was it hard?
Did you get better during the session?
How did you achieve baby steps?
50. Command & Query Separation
Commands:
void methods, change state
Queries:
return value, no side effects
SESSION 4
"TELL DON’T ASK"
Bertrand Meyer, "Object Oriented Software Construction“
51. "Procedural code gets information then makes decisions.
Object-oriented code tells objects to do things.“
Alex Sharp
"The big idea is messaging“
Alan Kay about OO
SESSION 4
"TELL DON’T ASK"
54. Whats wrong here?
point.setX(point.getX() + 1);
„Asking“ internal state and base calc on
Feature Envy
SESSION 4
"TELL DON’T ASK"
Bertrand Meyer, "Object Oriented Software Construction“
55. Push "Tell" into Point
point.moveRight();
SESSION 4
"TELL DON’T ASK"
Bertrand Meyer, "Object Oriented Software Construction“
56. Constraints
• Void only: no return values / exceptions
• Change only state in your own members
• or send messages to your neighbour object
SESSION 4
"TELL DON’T ASK"
57. Sync
What was hard?
How did you solve it?
What did you learn from it?
In which contexts does(n’t) it work?
SESSION 4
"TELL DON’T ASK"
60. SESSION 5
"FUNCTIONAL"
Constraints
No functional language
Minimize Mutability
pure functions
no mutable state
Expressions not statements
(if necessary: side effects only at the top level)
no ifs / switch
Name everything
Don't abbreviate
No primitive types nor anonymous functions / lambdas
Intermediary variables instead of chaining function calls
61. SESSION 5
"FUNCTIONAL"
Sync
• What was hard?
• How did you handle it?
• Difference to session before?
• What make sense for "real life“?
63. Choose one yourself
Your favorite of the day
Write your own Testrunner
No conditionals & no loops
Object Calisthenics
Only RegEx
SESSION 6
"YOUR CHOICE"
64. Sync
• What did you choose?
• What surprised you?
• What was hard?
• How did you handle it?
SESSION 6
"YOUR CHOICE"
65. • what did you learn today?
• what surprised you about today?
• what are you going to do differently
in your Project?
CLOSING
66. Please give us feedback about the
day on the feedback wall
so we can improve next time!
FEEDBACK