Grit: The Power of Passion and Perseverance by Angela Duckworth asserts that in life, effort counts twice. The way she illustrated this point was with a pair of mathematical expressions:
skill = talent * effort
performance = skill * effort
In other words, part of her thesis is that because practice uses effort to build skill, and then performance uses effort to employ skill, effort is a better predictor of success than talent is. She also argues that grit, a term which in her book means a combination of focus and tenacity, is a predictor of sustained effort, and therefore a predictor of success. I recommend the book; her argument convinced me, .
So I sat down at my computer to exercise some grit. But I immediately came up against a difficulty in applying Duckworth’s formula: When am I practicing, and when am I performing? Some of her examples in the book were athletes or musicians, people in two occupations with the sharpest possible distinction between practice and performance. But I don’t have an example of running laps or playing scales for programming. I mean, it’s really not clear to me what practice would be for a programmer.
Thinking of scales reminds me of my first piano teacher. “What are we doing when we play scales?” she would ask, “We’re thinking about what we should think about. When you’re playing scales, you should try to have perfect posture, you should try to have perfect tempo, you should try to have perfect dynamics.” In other words, she was telling me, “while you’re playing scales, you should focus on some aspect of your musicianship critically. Did that C and that D have the right volume, or did I accidentally play the C too loud? When I get to the top of the scale, where my index finger through my little finger go down in order, did I accidentally speed up?”
Duckworth recommends this sort of practice. One of the things she talks about in her book is the mindfulness of deliberate practice. In other words, great sprinters don’t just run around the track over and over again; they pick some aspect of their stride and try to improve it each time they run. They practice starting. They set concrete goals and measure their progress against them.
Athletics and music are somewhat dissimilar to programming in that they have clearly delineated times of practice and performance. I don’t spend hours a day refining my technique for writing software, and then write software for one glorious hour once a month; I write software all day, most days.
But there’s an important similarity: They both benefit from deliberate practice. That is, they both benefit from choosing a goal and exercising towards that goal. And I think it’s important that the goal be specific. After all, for piano, playing a scale “well” is not some abstract thing. It means, specifically, that you played with dynamic control (you had some deliberate shape to the loudness or quietness of the notes), that the tempo was even, that your posture was good, that your fingerings were correct. Do your ring finger and little finger strike the keys as firmly as your stronger fingers? Is your off hand keeping up with your dominant hand?
So this week, instead of trying to write code that is “good,” which is hard to measure and therefore impossible to practice, I’m going to try to write code that has clear variable and method names. I’ll still get the other parts of my job done, still get features written and bugs fixed, still test my changes and check in to version control, but I will add to my usual duties deliberate practice in naming things. I will try to ask myself, “Will anyone have to go to the definition of this field or property to figure out what it is? If someone sees only the signature of this method, will they be able to decide whether to call it?”
After I focus on naming things for a few weeks, I’ll shift focus to something else. I hope to take a small aspect of the code I write, and try to improve on it.
Do you have any suggestions for what to focus on while you code? Please leave a comment!
Till next time, happy learning,