A couple of years ago I attended my first Global Day of Coderetreat, a day to celebrate software craftsmanship and practice software development with like-minded developers outside of the context of a normal work environment.
I had a great time then, and so when I learned at the last minute that there was one coming up, I signed up for it right away. It’s a free local event, so there’s no excuse not to take advantage of it.
Last time we paired with different people in multiple iterations of developing John Conway’s Game of Life, with each iteration forcing us to throw away our old code and work under different constraints.
For example, one iteration asked us to avoid using primitives. At the time, I struggled to understand what it meant since you can’t create a custom class without using primitives at some point.
But the spirit of the exercise is that your solution shouldn’t expose implementation details. If you are using integer values to represent states, you could use a typedef:
typedef int State;
And then use State instead of int where appropriate. In this way, your code reads better because the way you model it is part of the language of the code.
Note how even with bad single-character variable names that
void update(GridPosition g, State s);
communicates intent a lot better than
void update(int x, int y, int s);
And ever since that coderetreat, I’ve been able to use that experience to write more readable code than I used to.
I’m looking forward to Saturday’s Coderetreat here in Des Moines, IA. It should be fun.
Are you attending a Coderetreat near you? Are you hosting?