One of the ideals we strive for and try to impart to our students at Grand Circus is clean code. Clean code is a broad topic deserving it’s own series of posts, but in brief, code is clean if it exhibits all of the following characteristics:
- Passes all tests (you are writing tests right?)
- Is as simple as it can be (KISS)
- Does not repeat itself (It’s DRY)
- Focused (functions and classes do one thing only)
That’s a lot, I know. As I said, clean code is a big topic. That’s why we spend a lot of time talking about refactoring code to a cleaner solution. Often your first pass at a solution is ‘sub-optimal’ which is a polite way of saying it smells. But that’s okay, writing code is like writing an essay. You make a first pass then you start editing (or refactoring in our case). Labs and projects are not always the best places to practice refactoring in a focused way because the stated goal is to get something working and having something that works is not always the same as having a solution that is clean.
Enter Coderetreat. From the Coderetreat site: “Coderetreat is a day-long, intensive practice event, focusing on the fundamentals of software development and design.” The format of a Coderetreat consists of a number of hour-long iterations in which we attempt to solve a small problem (we call them katas). We drive our solution using Test-Driven Development in pairs. The purpose is not necessarily to finish the problem. The point is to write expressive solutions that are free of duplication and driven by our tests. Since we’re liberated of the burden to get something working, we are allowed instead to focus on making our solution as clean as possible.
At Grand Circus we put our own spin on Coderetreats. In the typical format, a particular kata (Conway’s Game of Life) is practiced in each iteration. Game of Life can sometimes be a little daunting, especially for new coders. We also have some folks who’ve done Game of Life a lot. We usually offer another kata in addition to Game of Life that rotates for each iteration. But the base format remains standard for our Coderetreats. We work for 45 minutes on our chosen problem, test drive our solution in pairs.
When time is up we have a short stand-up retrospective (dialogue) on what we learned in the previous session. Did you try a new approach to this problem you’ve solved before? Did you learn a new design pattern? Are you starting to see the value of adding tests first? Did you do this kata in a language you’ve programmed in? (It happens.) Then we take a short 5 to 10 minute break, delete all of our code (yes all of it), and then start again. Recently we have tried some longer form katas, such Guy Royse’s excellent Vending Machine kata, these sessions tend to stretch over a couple of hours. At the end of the day we do a larger retrospective to cover the whole day. We like to find out what went well, what could have been better, and if anyone has any ideas on what we could do differently.
We schedule our Coderetreats such that all of our bootcamps have the opportunity to attend at least one. The response to these events have been very positive so far. We invite all of our students, alumni, as well as local professional software developers to attend. If you’d like to attend one of our Code Retreats we’d love to have you! There is no cost. We only ask that you have some prior coding experience. Contact us at firstname.lastname@example.org to find out when our next event is scheduled.