Search This Blog

Practicing Our Craft

The new year is nearly upon us, and you know what that means - New Year's resolutions. I didn't used to put much stock in resolutions, but for 2013 I resolved to start this blog and write a post every week. So far so good. Over that time I've talked a lot about the benefits of learning new things and practicing them to become a better programmer. I've realized that I spend much more time on the former than the latter, so this year I want to remedy that by spending a little less time studying and devoting that time to dedicated practice.

How will I actually do this practice? Software engineering is such a vast and complex field. Deciding what to practice can be paralyzing in and of itself, much less how to do it. When in doubt, head back to the fundamentals. I'll either be pulling out my old college algorithms book, or doing practice problems on different websites. As for how to do dedicated practice, there are a few guidelines that I think will help to get the most out of these practice sessions.

Stick to a routine. Practice won't be too useful if it's done haphazardly or inconsistently, and it certainly won't be dedicated without a routine. Like in weight lifting or playing a musical instrument, practicing consistently is probably the most important way to improve rapidly. Having a routine is a commitment, and with it, the practice is more likely to happen. It has served me well for these blog posts, and I expect it will do the same for programming practice. I'll start with a couple practice sessions a week to see what I can handle, and then see how things settle out.

Pick one thing. The purpose of practice is to learn something so well that it becomes second nature. To do that, you have to focus. That means picking one thing to focus on and practicing that one thing until you don't have to think about it anymore. Practice until you can do it while carrying on a conversation. Practice until you can think a few steps ahead of the code you're writing while doing it. Practice until it becomes harder not to do it. So what is 'it'? 'It' can be anything from a new language feature that you want to learn to a keyboard shortcut in your editor that you're trying to add to your repertoire. Whatever it is, make sure to focus on it exclusively to learn it faster. And exclusively doesn't mean for inordinate amounts of time, either. You can focus for short amounts of time before moving on to something else, but don't try to practice more than one thing at once or you'll slow yourself down.

Get rid of bad habits. We all have them. We should be aware of them. The trick is to get rid of them. The best way to get rid of a bad habit is to realize when you're doing it and stop it right then and there. Don't allow yourself to do it wrong just this time with the excuse that you'll do it better next time. Do it right this time. Check in your code right now before doing that refactoring. Write the test first this time. Take the time to write smaller functions with good names now, not later. These are only examples, but they are probably common examples. The point is to identify your bad habits and fix them right away. Above all, do not practice bad habits. You play like you practice, so practice how you want to play and do it well.

Practice in bursts. This advice is probably not what you think it is. I'm not talking about practicing for ten minutes, then taking a break, and then practicing for another ten minutes. I'm talking about practicing a very small, discrete skill over and over again, and then using it within a larger exercise. I learned this technique from my guitar teacher as 'bursting', and it is used a lot when learning musical instruments, typing, or any skill that requires developing a lot of muscle memory.

When learning to play a new guitar piece, I would practice a difficult measure or even a single chord transition a number of times, maybe ten or even twenty times in a row, and then play through the whole piece without stopping. If the difficult part came out easily, I would move on to practice another part of the piece. If it was still hard, or I hesitated, I would do another burst. You'd be surprised how quickly you can smooth out rough sections of a song with this technique. The same goes for learning difficult skills in programming, and like the principle of picking one thing, it could be any distinct, well-defined skill that needs practicing.

Make it harder to make it easier. Do you remember how hard it was to understand scoping rules for function parameters the first time you were learning them? I remember that being the first thing that really confused me when learning to program. It was all a big muddle at first. I also remember thinking function parameters were so easy by the time I was learning about class member scoping rules and method overloading in C++. Then templates made those things look easy by comparison as well. Doing something harder and pushing yourself beyond your previous limits makes things that used to seem hard now look easy.

Many sports have ways to intentionally make practice harder than the real game to take advantage of this principle. Have you ever tried to downhill ski on one ski? I mean physically remove one ski and then go down, leaving it at the top of the run. Yes, you still have to turn. You can't just bomb the run and hope for the best. This was a standard drill when I was on the ski team in high school, and we did it through slalom gates. Once you could ski on one ski, doing it with two was a piece of cake.

How about swinging a golf club with only your left hand? How about only your right hand? How about playing soccer or tennis with ankle weights? How about swimming laps with three suits on? These are all ways to make these sports more difficult so that real play is easier, and you are subsequently better. So the next time you think the problem you're working on is hard, try making it harder. The real problem might suddenly seem easy by comparison.

So that's the plan for the coming year - real practice to improve at programming faster. This set of principles is a nice, easy to manage regimen that should help make the most of that practice. You don't want to complicate things too much because you need to keep your mind on what you're practicing. Stick to a routine and pick one thing to focus on at a time. Sometimes that one thing will be a bad habit to break. Other times it will be a difficult concept or skill that needs to be practiced with bursting. And if something is not making sense, try moving past it to something harder. Trying to understand things at the next skill level may help everything fall into place.

No comments:

Post a Comment