This past Saturday, I attended the Atlanta Code Retreat at the Highgroove office. I hadn’t been to a code retreat before this one, and I really didn’t know what to expect. What I got a was a challenging but fun day of pairing with five different developers, and writing in four different languages.
The basic idea of the retreat was not to focus on coding a complete solution, but rather to write the best code possible. We were aiming to write small pieces of well-tested and DRY code that showed its intent through good naming.
The day was divided up into six sessions of 45 minutes, and in each session, we were paired with a different developer. The task was to code Conway’s Game of Life, with a new set of contraints for each session.
By the end of the day I had written code in Ruby, PHP, Java and CoffeeScript, and worked with developers with different levels of experience. I got the chance to use editors and even operating systems I had never used before.
Two sessions were especially challenging. In one session, we weren’t allowed to use any conditionals or loops. This was designed to push us towards using functional programming techniques, something we don’t do a ton of as Ruby developers. And in another session, we kept our pairs from the previous session and inherited another pair’s code. This was challenging because many groups got code in languages they weren’t experts in.
I found the “ping-pong” session to be the most interesting. One developer wrote a failing test and handed over control to the other developer. The second developer wrote the code to make the test pass, and then they wrote another failing test. When writing the code to satisfy failing tests we were encouraged to be “nefarious,” meaning that we wrote just enough code to make the test pass. For example, if the test was checking that some method returned 2, we would simply make that method return 2. Then we’d write the failing test to improve the code.
Key takeaways from the event for me were:
Pairing is fun and productive! It is awesome to have someone with whom to work through a problem. A good pair will often catch your mistakes before you do. What’s more, you will likely create a more elegant solution than you would be able to do your own.
Testing is very important. Not only does it serve to validate the correctness of your code, it also serves as documentation for what your code does. When our pair inherited an incomplete CoffeeScript implementation of the game, we were happy to find that there were accompanying tests that made it easy to figure out what was done, as well as what still needed to be worked on. We were also able to continue development with the assurance that we weren’t breaking existing functionality.
While Ruby is awesome, using other languages can be fun. Writing in other languages makes you grow by encouraging you to think about things in new and different ways.
Code Retreats are a great way to sharpen your existing skills while learning new ones. What other types of events do you participate in to hone your skills?