Skip to main content
Baby Steps TDD
Approaches
Softwerkskammer Meetup Munich
@codecentric
09.04.2015
David Völkel
Agenda
● Pizza
● Theory
● Coding Kata
● Another beer
Baby Steps
● Who knows the notion?
● 2011 Kent Beck‘s
Responsive Design
● 2013 Adi Bolboaca
Taking Baby Steps
● 2014 Seb Rose & …
Diamond Kata
● [2014 Mikado Method]
How I stumbled upon…
Leap
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
Stepping Stone
change 1
Initial state
change 2
state 1
state 2
…
change n
target state
get green asap
● commit on green
● revert to green
+
Stepping Stone
change 1
Initial state
change 2
state 1
state 2
…
change n
target state
+ fast feedback
+ less risk
- a bit more effort
"Taking Baby Steps“
Kata Contraints (Adi Bolboaca, Erik Talboom)
● Write Feature
● Test
● Implement
● Refactoring
2 min.
2 min.
red?
green?
git reset --hard
git commit
The “Diamond Kata“
A => A B => _A_
B_B
_A_
C => __A__
_B_B_
C___C
_B_B_
__A__
Parallel
● Old and new version
parallel at the same time
● Switch one usage at a time
old
create
new
delete old
old not used
anymore
My too big Feature
Simplification
baby
feature
Layer 1
Layer 2
integrated test against vertical slice
My too big Feature
Simplification
baby
feature
Layer 1
Layer 2
Narrow focus of test
C => __A__
_B_B_
C___C
_B_B_
__A__
C => __A__
Outside-In TDD
Feature
Layer 1
Layer 2
Unit test
Mocks
Component
Feature
Layer 1
Component
Helper Class vs. Method?
Unit test bottom up / inside-out
On-Site TDD
• Temporary assertions in production code
• Delete afterwards
• Even quicker: a REPL
public String diamond(String s) {
if (s.equals("A")) {
return s;
} else {
assertEquals("A", predecessor(s));
return (predecessor(s) + s);
}
}
Test-Recycling
• Start with simple test
• Subsequent rewrites of the
same tests
B => AB
B => ABB
B => AnBBn
Let‘s code the “Diamond Kata“!
Contraints "Taking Baby Steps“
● Write Feature
● Test
● Implement
● Refactoring
● [Don‘t talk]
A => A B => _A_
B_B
_A_
C => __A__
_B_B_
C___C
_B_B_
__A__
2 min.
2 min.
red?
green?
git reset --hard
git commit
Retrospective
Images
THOR
https://commons.wikimedia.org/wiki/File:Parkour_leap_of_faith.j
pg?uselang=de
Seattle Municipal Archives
https://commons.wikimedia.org/wiki/File:Kids_at_Kubota_Garde
n_2003.jpg
License
Creative Commons Attribution-ShareAlike 3.0
https://creativecommons.org/licenses/by-sa/3.0/de/