In our weekly learning sessions, my team are working through Agile Technical Practices Distilled, a great coursebook written by my friends Pedro, Marco and Alex. Last week I hosted a quiz game to practise recognising and refactoring code smells.
Context
In previous weeks, we’ve used extreme learning sessions to work through the catalogue of code smells in Martin Fowler‘s Refactoring: Improving the Design of Existing Code. This exercise is useful for giving everyone an initial awareness of the names and descriptions of the smells, and we spent a little time on each smell discussing examples we had seen recently. But a single discussion of each smell isn’t enough to form a long-lasting, active memory of the concept, so it’s useful to revise this knowledge and put it into practice.
Pedro, Marco and Alex have already done the ground work for this by creating a repository with very smelly implementations of TicTacToe. Rather than approach this individually or in pairs, I felt that this exercise was best approached as a whole team, as discussing the code would help us deepen our understanding of the issues. To make it more interactive, I ran the session as a quiz.
Running the Quiz
I already had flash cards for all the code smells from our extreme learning session, so our only preparation was to open the repository on a few laptops so we could all browse the code.
Once we knew our way around the code, I held up the first flash card, and invited the team members to buzz in* when they had spotted the smell in the code. I then gave them a chance to explain their answer and, if they had accurately identified the smell, they got to keep hold of the card to keep score. (*We didn’t have buzzers, so we made do by tapping on the desk.)
Once we had identified the smell, we spent a few minutes refactoring the code to remove it. To keep things flowing, I acted as driver, and asked the team members to navigate me through the refactoring steps. We didn’t do any refactoring that didn’t relate to the smell we had identified, even if we were sorely tempted! That had to wait till an appropriate smell had been identified.
Once our current smell was eliminated, I selected the next flash card, and we continued the quiz.
At the end of the session, we counted up the cards each team member had won; congratulations to Lewis and Roberto for being joint winners with 2 points!
Observations
This proved a simple way to run an energised discussion. As I had suspected, not everyone could remember all the smells, and we were able to spend a moment revising each one before we started trying to spot it in the code.
It was also extremely tempting to tackle other issues in the code at the same time as the current smell. I have a feeling that enforcing the discipline of addressing one smell at a time can help us break our code changes into smaller increments.
Overall, I would certainly run this session again, and would recommend it to other teams who want a fun way to increase their shared understanding of software design principles.
Hi Matthew, thanks for your post. I’ve run the quiz with my team and it was really fun. Cheers!