Improving software quality is an ongoing effort at InnoGames. Software products with lifetimes of several years like our games need to be sustainable and well crafted. Some methodologies to help with this are Test Driven Development (TDD) and Pair Programming. However, developers sometimes find it hard to get started with TDD or do not feel comfortable enough to apply these methods in their daily workflow.
Take your time to practice
Commonly time to try new things or improve some of your skills is short in the daily routine. There are always tasks that need to get finished. But how should we get better at what we are doing? Take a look at musicians: They practice a lot before they enter a stage and so should we as developers. So how often do you take your time to sit down and just practice a certain coding skill? Code Retreats address this problem by explicitly stepping back from daily business and taking a full day off without pressure, focusing on practicing and trying new things.
The Game of Life
A common exercise to work on in a Code Retreat is Conway’s Game of Life. We at InnoGames also approached this topic in the first Code Retreat we held in October. The goal of this exercise is not to implement a fully working game of life, but to focus on the design and implementation techniques. And there are some special requirements for the working process:
- do Pair Programming (driver / navigator)
- do Test Driven Development
- work in short iterations (45 minutes)
We did 6 iterations in total, 3 before lunch and 3 in the afternoon. For each iteration there is a different aspect to focus on. This might be things like choosing good names, training to advance in baby steps, keeping methods short or using polymorphism instead of control structures. After an iteration is finished you have a short retrospective with the whole group to discuss the findings and problems.
Then comes the fun part: You delete your code, team up with a different partner and start over again. This feels a little odd in the beginning, but remember: we want to learn and get better. This is not about “getting things done” but “getting things right”. So you can start again with a blank canvas and maybe choose a different direction in the next iteration.
In some iterations you might end up with nearly writing no code at all. Instead you are discussing with your partner on how to solve the problem. But that’s ok, we can learn from different perspectives on software design.
A second Code Retreat workshop we held in February dealt with a slightly different topic: Legacy Code. Instead of developing a codebase from scratch, we tried to approach some existing (and admittedly very bad) code. The aim for this workshop was to find and practice ways to refactor bad code but at the same time ensure through tests, that we do not break functionality. The aim of the first iteration is to find a golden master test, that touches as much of your codebase as possible. With this test you are then able to compare your new (refactored) implementation against the old implementation on a high level. In later iterations you go further into detail and start to apply different refactoring techniques like extending some classes and overriding methods with new implementations, finding and eliminating code duplicates, extracting pure functions without side effects to move them into new classes, and so on. Also here it feels relieving to know that you will throw away your code and you cannot break anything. Just try your best and see if your approach will lead to better code.
From my experience code retreats provide a benefit in various areas. Just to name a few:
- getting more familiar with Test Driven Development
- practicing Pair Programming
- getting to know other colleagues (teaming up with people you usually do not work with)
- learning new ways to work with your IDE
- getting your hands on a new IDE (on your partners computer)
- knowledge sharing and discussions on software design and testing in general
After all it was a really refreshing experience and I can recommend participating in a code retreat to every developer.