Earlier I did a post on creating a practice space to learn Test Driven Development. We listened to my advice and did this at Thoughtcorp. Over several months we did a single 1 hour session per week.
We followed a basic format:
- Get together in a group.
- Talk for a short time (5 min) about the problem we are solving or a new concept to add to our practice.
- Pair up.
- Work on the problem for 45min.
- Come together and debrief with what we learned and observed.
- Recount of our experience
We didn’t stray from the format, however we did change around the problem we were trying to solve and the constraints we put on it.
When we started, the only explanation were the 3 laws of TDD and to challenge your pair to get the test passing in less than 30 seconds. We used Conway’s Game of Life as the problem to solve and deleted the code at the end of the session. We used this for about 4 weeks, at the end of that time the general observation is that everyone was getting tired of working on the same problem.
The week after we changed to do the Bowling Game, this caused a resurgence of energy in the group. During several weeks of working on the bowling game, we experimented with keeping code to be used the next week. Keeping the code around, did in at least one case allow for a greater understanding of refactoring. When you showed the code to the new person you were pairing with, they would point out areas of the code that didn’t expose their meaning well. Again after 4-6 of doing the bowling game, the energy level around that problem dropped.
The following week we moved to some simpler katas like Fizz Buzz, Backwards Talk and Roman Numerals. These allowed for pairs to choose what they wanted to work on and they could have complete solutions inside the 45 minutes. This definitely was rewarding outcome. It also meant that the solutions were so small and easy to visualize that more energy was put into refactoring and how small the tests could be.
Another variation we added was to do the simpler katas but follow the Object Calisthenic rules. This really drives at writing Object Oriented solutions. I plan to cover Object Calisthenics in more detail in a future post, stay tuned for that.
Observations
The Game of Life and the Bowling Game are katas that have a large solution space and many developers primarily focus on creating the solution. The act of TDD and refactoring and Object Oriented (OO) design take a back seat in these problems, at least when they are first learning the practices.
Small, katas made the act of solving the problem so simple that focusing on how you practiced TDD became the challenge. However these problems are small and don’t really benefit from really good OO design. Which means most solutions would end up as single methods with a few if statements. This allows for good TDD some refactoring, but not much practice around OO design.
Object Calisthenics forces you to refactor and look for better OO design to stay in compliance with the rules. These constraints changes simple problems in to much more challenging ones, the solutions are much less obvious and you have to listen to your tests. It makes you really work your OO design muscles.
The 10 minute debrief at the end is the most valuable part of the session, don’t skip it. This is were everyone shared what they learned or had difficulty with. Everyone has a different point of view, and those really help everyone else learn.
Conclusions
1 hour a week is a great starting point to help build up your TDD skills and introduce everyone to Deliberate Practice. Everyone that attended the sessions regularly, felt more confident in using TDD and had a lot of fun doing it.
Our team got a huge pay off, we were able to practice TDD in more areas of the code base than before and all of our automated tests became more effective and easier to write.