Music and Code: How to Practice
Last week I wrote about how practice is at the heart of art, whether it’s music or programming. I learned how to practice from my first great teacher, Mike Gross. Here’s what he taught me:
Practice a piece two ways: once as slow as necessary for every note to ring clean. Then again at the correct tempo, ignoring any mistakes. Increase the tempo of the first until you’re playing clean at full speed.
Record yourself practicing. Listen back to it and take notes. It’s amazing how much of what you think you’re hearing with your ears while you’re playing is being imagined by your brain.
Only practice as long as your energy lasts. Once you start to fade, more practice hurts. Practice doesn’t make perfect, it makes permanent. If you practice sloppy, you’ll perform sloppy.
Pay attention to the smallest details. Let each note ring as long as it should, no shorter or longer. Mute the strings you aren’t intentionally playing. Right hand position towards the bridge or neck can have a huge effect on tone.
Practice like it’s a performance. Practice taking your instrument out of the case and plugging it in the same way every time. When you go on stage, going through the same motions will give you confidence.
Here’s how the same advice relates to programming:
Fine tooth comb your program, then let it go. Repeat! Nothing is less useful than a program that doesn’t get released. At some point, you have to release something, warts and all. Go back and rewrite it afterwards. The art of programming is largely the art of rewriting.
Accept feedback on your programming without defense. In music, the recording forces you to reckon with what you sound like. Some programmers try to argue with their peers’ feedback, or find a reason to internally dismiss it. You have to consider the source of the feedback to some degree, but evaluate it as impersonally as possible.
Monitor your energy levels and mood while you’re programming. When you’re tired or frustrated your judgement is impaired. The worst of the worst bugs overwhelmingly get created late at night.
Pay attention to the smallest details. Name functions and variables with intention. Make meaningful comments in version control. Track where you spend time on a minute by minute basis, and minimize waste — use the keyboard “home row” as much as possible, create aliases for common commands, write scripts for common tasks.
All code is important. Don’t cut corners in your tests because “it’s not production”. Don’t treat some parts of the business like second class citizens.