Coding == Practice

In my other life I’m a musician—a guitarist who plays in a band. I used to tell my guitar students that it takes literally miles of practice—DAILY practice—up and down the guitar fretboard to feel comfortable improv-ing a solo on the guitar with a band. I could always tell the students that practiced a little every day versus the ones who thought they could practice for three hours once a week. The ones who practiced just minutes every day always improved more rapidly.

One of the tools I used in my own daily practice routine was called Pentatonic Power by Bob Murnahan. The thinking is that musicianship is like language— you practice daily on committing to muscle memory the various pieces of the language’s vocabulary, so that you have at your command the ability to combine those pieces together into interesting ways.

The key here was that practice of these vocabulary pieces was to be a daily endeavor to be successful. Daily repetition committed the vocabulary building blocks to muscle memory. For daily repetition to be possible, it was essential that they were small units of work.

I think the same is true in my software programming life. Just as it takes miles up and down the fretboard to have command of the instrument, I believe it takes miles back and forth across the keyboard to master the vocabulary pieces—the algorithms and idioms—of a computer language, or even of software engineering and problem-solving in general.

Dave Thomas, an important figure in the Ruby Community and Pragmatic Programming wrote a blog post several years back on this same idea, but couched within the notion of a “kata”, where the value of practice is emphasized when learning a creative process. He says,

“…see if you can carve out 45 to 60 minutes to play with a small piece of code. You don’t necessarily have to look at performance: perhaps you could play with the structure, or the memory use, or the interface. In the end it doesn’t matter. Experiment, measure, improve.

Practice.”

I didn’t have the benefit of the hours of practice that naturally are a result of being a computer science major in university while completing class assignments. I had to make up for it on my own with daily practice. Dave’s suggestions ring true. If I can take 30-60 minutes every day to code a solution to a problem, I find that coding is more embedded in my “muscle memory”, and it makes me a better on-the-job programmer.

To that end, I have always been looking for “exercises” to add to my daily routine. The aforementioned blog offers several suggestions as katas, and there are links to the Ruby Quiz as well. The language typically doesn’t matter, as most translate to any programming language you choose. The point is to get your brain and your fingers adept at solving problems in code.

What other lists of coding exercises have people discovered useful?

Comments