I am a programmer and architect (the kind that writes code) with a focus on testing and open source; I maintain the PHPUnit_Selenium project. I believe programming is one of the hardest and most beautiful jobs in the world. Giorgio is a DZone MVB and is not an employee of DZone and has posted 635 posts at DZone. You can read more from them at their website. View Full User Profile

Global Day of Code Retreat 2013

12.13.2013
| 793 views |
  • submit to reddit

Like for every year in December, it's almost time for the Global Day of Code Retreat. This year more than 160 local Code Retreat events are registered, for a grand total of more than 3000 developers participating.

What is a Code Retreat

A Code Retreat is a small event where from 10 to 30 developers exercise in 6 iterations on implementing the Game of Life (the reference exercise). The goal of the event is for developers to learn that deliberate practice is necessary to improve, and to see several new approaches, languages and tools to exercise on in the near future.

Talent is overrated: while sprinters need the DNA to become top-level performers, the knowledge workers and in particular the programmers talent comes from practice that is challenging (not easy to perform), repeatable (to automate the movements in our brain and muscles) and subject to feedback from other on how to improve.

In the Code Retreat, the challenge is ensured by constraints on the problem (such as not using conditionals, or working in strict TDD if you have never done it before.) The repeatability is instilled by the 1-hour sessions at the end of which all code is deleted. The feedback is provided via mandatory pair programming and during a 10-minute retrospective at the end of each session.

The Game of Life

The problem to solve has interesting properties. It's part of the cellular automata category, and consists of a potentially infinite 2-dimensional board composed of square cells that can be in an alive or dead state. Being the cell squares, each has 8 neighbors.

In discrete steps of time, each generation of cells evolve into the next generation, according to the 3 rules:

  • if an alive cell has less than 2 alive neighbors, it dies of solitude.
  • If an alive cell has more than 3 alive neighbors, it dies of overcrowding.
  • If a dead cell has exactly 3 alive neighbors, it comes to life of warmth.

These 3 simple rules result in an emergent behavior which produces interesting patterns on the board, whose population remain stable over time. If you change them a little bit, the pattern usually explode to take over the entire board or disappear after a few iterations to leave behind a dead world.

Usually what is of interest in the Code Retreat is to build an engine that is capable of simulating in memory the behavior of some cells or even the infinite plane.  The user interface can be added later and if there is enough time, since the automated tests already give feedback on the working state of the code.

The variations

It's not easy to solve the Game of Life problem and build a complete simulation of it in the allotted 45 minutes, but that is not the point nor the difficulty level to strive for. Difficulty should be in working in a clean style with respect to the quick&dirty style diffused in our industry; the quick part will come back later when we have learned to do things well.

Published at DZone with permission of Giorgio Sironi, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)