I've taken up Exercising

I have been having fun participating in Exercism.io - a collaborative code improvement site started by Katrina Owen.

The rules are simple: You get an exercise with a README and a test suite. You make the test suite pass, submit your code and the other participants can nitpick the submitted code. It’s actually quite fun - even for us experienced developers.

Here are a few of my takeaways from having done a couple of exercises there.

There are many ways to do things

There’s rarely The One True Solution. Everybody tends to solve the problems in slightly different ways. Looking through other peoples submissions, noting the differences and reasoning about why they’ve done something one way or the other, is quite valuable.

Even old dogs can be taught new tricks

I’ve been programming since forever, professionally for 13 years, in Ruby since 2004. I like to think I’m good at what I do and that my code is squeaky clean.

That said, there has always been something to nitpick and I have always been able to improve code after submitting it.

Rubys Core Library is awesome

In my daily work as a Rails developer I tend to live in the comforting blanket of Active Support. This has the side effect that I can never remember what methods come from Active Support and which come from Ruby.

It turns out a ton of the awesome stuff comes from Ruby and I’ve been giving Active Support credit for them. Duly noted.

My workflow

Looking at the code I’ve submitted and the feedback I’ve received, a trend emerges: I tend to make a super simple, working program first. Then overengineer it. Then simplify it, but not making it so simple as the beginning. And occasionally I end up going back to the simpler, first revision.

Sleeping on it

Ignoring ones knee-jerk reaction in code reviews is a good idea. Often I’ll react to a nitpick by thinking “no way, that’s not better than the perfect code I already wrote”. However, often after having the idea lingering in the back of my brain for a while, I’ll end up submitting a new version anyways.

Exercises aren’t the real world

An exercise is by nature fairly trivial. Few of the exercises will prove difficult for an experienced developer. Had we faced the same problems in The Real World (tm) we would likely solve it differently.

Out there, things like deadlines and an ever increasing backlog loom over us, forcing us to evaluate the effort involved in improving code versus the gain from the improved code. When exercising we should set that aside and strive to improve for the sake of improving.