Coderetreats are free day-long, intensive practice events, focusing on the fundamentals of software development and design. By providing developers the opportunity to take part in focused practice, away from the pressures of "getting things done", the coderetreat format has proven itself to be a highly effective means of learning and nurturing software development skills. (from https://www.coderetreat.org)
- Problem: Conway's Game of Life: https://en.wikipedia.org/wiki/Conway's_Game_of_Life
- Length of each session: 42 minutes
- Prefer using Test-Driven Development (TDD)
- The same exercise is repeated multiple times during the time of the code-retreat
- Short debrief time after each session
Pair-programming is necessary
After each session, change your partner
After each session, code must be deleted, not put in a branch, not stashed, just deleted with no trace left
The result of each session is the collaborative learnings you experienced with your pairing partner.
The universe of the Game of Life is an infinite, two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, live or dead (or populated and unpopulated, respectively). Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:
- Any live cell with fewer than two live neighbours dies, as if by underpopulation.
- Any live cell with two or three live neighbours lives on to the next generation.
- Any live cell with more than three live neighbours dies, as if by overpopulation.
- Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
- TDD + Ping-Pong (write test / code)
- TDD As If You Meant It (i.e. Strict TDD)
- Evil partner
- Silent Pairing
- Object Calisthenics
- Immutable
- Choose your Constraint(s)
- Fluent Style: newX.withYAt(1).withZ()…build();
- No Mouse, or No IDE (text editor only)
- No conditional statementsNo loops
- No TDD
Even more constraints: https://www.coderetreat.org/facilitators/constraints/
- Write exactly one new test. It should be the smallest test which seems to point in the direction of a solution
- Run the test to make sure it fails
- Make the test from (1) pass by writing the least amount of implementation code you can IN THE TEST METHOD.
- Refactor to remove duplication or otherwise as required to improve the design. Be strict about the refactorings. Only introduce new abstractions (methods, classes, etc) when they will help to improve the design of the code. Specifically:
- ONLY Extract a new method if there is sufficient code duplication in the test methods. When extracting a method, initially extract it to the test class (don't create a new class yet).
- ONLY create a new class when a clear grouping of methods emerges and when the test class starts to feel crowded or too large.
- Repeat the process by writing another test (go back to step #1).
- Wrap all primitives and strings
- Use only one dot per line
- Don’t abbreviate
- Keep all classes small
- Don’t use any classes with more than two instance variables
- Use first-class collections
- Don’t use any getters/setters/properties