Fluency with TDD
It takes a lot of practice to get good at TDD. This is a learning hour for when you’ve already done a few katas and are starting to get the hang of it.
Learning Objectives
- Remember the steps of the TDD cycle
- Use TDD consistently when developing a function
- Evaluate which aspects of TDD you’re not yet fluent with
Session Outline
- 5 min connect: Benefits of TDD
- 10 min concept: Fluency
- 30 min do: Word Wrap
- 5 min reflect: own practice goals
Connect - Benefits of TDD
Put this question to the group, and ask them to come up with 5 answers.
“What are 5 important things to remember when you’re doing Test-Driven Development?”
The kinds of answers you’re looking for are:
- take small steps, testing one thing at a time
- run tests often
- refactor test code as well as production code
- only refactor when tests are passing
- make a test list
- write the test first
Concept: Fluency
Tell a story about learning a skill like dancing or cooking or skiing or playing a musical instrument. Something from your experience. The key part of the story is telling them about a time you found you could do the new thing in the class, with the teacher, in ideal conditions, but not at the same time as doing something else. It’s the difference between having a skill, and having it fluently. When you get a bit stressed, and have to devote most of your brain to thinking about something else, if you can still do the skill, then you’ve got some fluency with it.
Today we’re training TDD fluency. You get good at doing something by practicing it and reflecting.
Do: Word Wrap
Practice breaking the problem into small pieces by making a test list. Practice writing the design in the test first before you create the function. Practice making the tests pass one at a time. Practice updating your test list. Practice refactoring to remove duplication. Suggested kata - Word Wrap.
For each aspect of TDD that you’re practicing, pay attention to how fluent it feels and how easily you can do it.
Reflect: own practice goals
Refer back to the list of what’s important in TDD that you made earlier. Which aspects of TDD do you need to become more fluent with? Which parts were hardest for you? Perhaps ask people to dot vote, or make notes for themselves. Perhaps you can do some practice by yourself or your coach can arrange more learning hours focussed on those parts.