Thursday, January 6, 2011

Code Retreat

Test Driven Development: By ExampleAt agile 2010, Rob Park introduced us to code retreats. This is where software craftsmen from all over get together to do several iterations of pair programming and test-driven development. Developers pair up to try to solve Conway's Game of Life. Each iteration is 45 minutes, followed by a retrospective. Before each new iteration, code is deleted and pairs are swapped. The idea is to experiment and try coding with bottom-up or top down, using no ifs or no loops, etc. Practice the fundamentals of TDD by coding using “TDD as if you meant it”:

1. Write exactly 1 failing test
2. Write implementation code in the test to make the test pass.
3. Create new implementation methods only by extracting out the working code from the test.
4. Create these new methods in the same test class.
5. Extract these new methods from the test class into implementation classes.
6. Refactor as required.
7. Repeat

The rules for Conway's Game of Life are:
  •  Any live cell with fewer than two live neighbours dies, as if caused by under-population.
  •  Any live cell with more than three live neighbours dies, as if by overcrowding.
  •  Any live cell with two or three live neighbours lives on to the next generation.
  •  Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
The first generation is created by applying the above rules simultaneously to every cell in the seed—births and deaths occur simultaneously, and the discrete moment at which this happens is sometimes called a tick (in other words, each generation is a pure function of the preceding one). The rules continue to be applied repeatedly to create further generations.

Others have tried retreats using games like tic-tac-toe or Go. Find out more at http://www.coderetreat.com/how-it-works.html or check out the next code retreat coming to a neighborhood near you at coderetreat.ning.com/events