Dalke Scientific Software: More science. Less time. Products
[ previous | newer ]     /home/writings/diary/archive/2007/08/17/kata_and_practice

Kata and practice

What's a Kata?

Emily is doing Code Kata, in the context of a Coding Dojo. There are several such dojos, including one in Finland and another in Paris. Quoting the Finnish site:

A Coding Dojo is a coding session centered around a programming challenge. The challenge is small in scope and often patterned after pragmatic Dave Thomas' idea of Coding Kata. This event is based on Laurent Bossavit's monthly Coding Dojo in Paris where it has been running on a weekly basis since January 2005. It has been a weekly programming class where programmers of varying skill levels meet as equals.

The terms come out of Japanese martial arts. The dojo is the practice hall and a kata is a set of exercises where the student follows the teacher in repeating well-defined motions. Emily is part of a group which works together to implement the challenge problem. They might do the same problem multiple times in different sessions, in order to explore solution and implementation space. For example, trying different algorithms, or using Python one time and Ruby another.

I don't have a martial arts background. I take that back. I did almost three years of fencing in college and grad school. Okay, I don't have an Asian martial arts background. The hierarchical teacher/disciple relationship bothers me. So I use different idioms to think about this problem.

I also used to play piano. Once upon a time I ranked second in Florida in my age group and experience level, and I got a special honor award at the county youth fair. I was about 8 or 10 or so. But piano did not have a strong draw for me and I didn't practice anywhere near as much as I would have to keep along with others.

Part of practice was to focus on techniques. My ex-roommate in grad school tells of a famous musician who was asked about the hardest piece to play. He responded "scales, slowly." One of the technique books was by Carl Czerny. He wrote a series of etudes for the piano, étude being French for "study." They were meant for students to practice different techniques.

A kata is rather like an etude. You practice them and practice them. The goal is to get the moves down so you don't need to think about them, which lets you work on the more complicated task of making it all go together.

If that's the case then the idea doesn't translate that directly into a coding kata. While Emily's group works might work on the same problem multiple times, they don't implement the same solution each time. They try and contrast different approaches. This is more like a "practice piece" or a "study." Dave Thomas himself expands on the idea and talks about other components of skills acquisition, which he calls kumite and koan and relates to the "Dreyfus model of skills acquisition"; which does not have a Wikipedia page.

The Dreyfus model

The model comes from the 1980 [1] work of Hubert and Stuart Dreyfus, and was applied to nursing by Patricia Benner [2]. Andy Hunt * imported this idea into programming in his talk titled "Herding Racehorses and Racing Sheep." (I can only find PPT copy from RTP-Spin; Google's HTML cache.) By far the best page giving context for this is by Jeff Atwood of Coding Horror, including the comments.

The idea is that skills aquisition is a continum, which can usefully be categorized into the levels: beginner, advanced beginner, competent, proficient, and expert. I originally used the list from Jeff Atwood's page, which is extracted from the PPT presentation, but I disagreed with the "Doesn't want to learn" characteristic of a beginner. There's a less contentious example of applying the Dreyfus model to learning Ruby on Rails and compare also to a medical page describing the Dreyfus model. I've merged them here:

Applying the model to hard skills

I think the comparison to learning Ruby on Rails is kinda stupid. Skills come in different difficulties. Learning the binary search algorithm is a skill, but it's different than learning automata theory. RoRs is somewhere in between those two. I'll go with the idea that it takes more than 5 years to master a field, spending more than 20 hours a week on the topic. Rough guideline and there are plenty of other, perhaps better ones. Some say 10 years, and my advisor said "thinking about the problem every waking moment." I've also come across phrases like "rage to master" and "deliberate practice". My point is that some skills are a lot harder than others.

The two new and complicated skills I've started learning in the last 10 years are dancing and Swedish. I've danced salsa for 7 years and tango for 3. For about a year I was dancing more than 20 hours a week, with salsa, tango, swing, and Scottish country dancing, including going to clubs 3 or 4 times a week. I am a good dancer. Watching clips from "You Think You Can Dance?" I realize that I am not an expert dancer, by a long shot. But put me in almost any salsa or tango club and I'll be one of the top 10-20% of the people there.

At that point it depends on what "best" means. There are some people who dance a different style than mine and we can't dance with each other. These seem to be mostly people who learned to dance competitively, as there are a set of expectations there which aren't in club-style dancing.

Hmm, but "expert" is not the same as "best." In the domain of "dance" I am perhaps "competent". I know nothing about modern dance, or Bollywood-style dancing, or African dance. In the domain of "salsa dance" I am perhaps "proficient." But in the context of "people you're likely to meet at a salsa club" I'm an expert.

This confusion isn't giving me a warm, fuzzy feeling about the applicability of the Dreyfus model to dance, as defined previously.

Here's another example. In college I worked at the math help center. I was the local expert on how to do and explain the sorts of calculus problems found in undergraduate math courses. This was because I had taken a year of real analysis (a 4th year, or 1st year graduate level, course which works through the mathematical underpinnings of calculus. But I was not an expert at math. On the other hand, only a few of the top scientists in the world in the late 1600s could do basic calculus, now taught in many high schools.

Language is also hard to fit to the Dreyfus model. I've known foreigners who lived in the US for years, went to college and grad school there, but because they didn't live through the 70s and 80s they didn't get cultural references which were part of "expert" speech. But I wouldn't be able to explain the linguistic or esthetic reasons for why English structures things one way and not another. For example, why do most European languages use grammatical structure like "I slept not yesterday" while English uses "I didn't sleep yesterday." The theory I've learned about recently which tickles my fancy the most is that it's a Celtic influence on English.

Am I an expert in English? What's the domain of applicability to the Dreyfus model? Perhaps these really big domains are too much for it?

I question the usefulness of having 5 different levels. One analogy I like is that programming is a craft. I am far from being the first to suggest this. We already have language for describing levels of skill acquisition in a trade: apprentice, journeyman and master. Only three levels there. Four if I add n00b :).

Some poking around on Wikipedia, starting with "skills" and "learning" brought me to The Four Stages of competence: unconscious incompetence, conscious incompetence, conscious competence, and unconscious competence. That's four levels. But as far as I can tell the term "four stages of competence" is a purely a business/pop-psychology term. Just reading the definitions makes me want to gag. "We management consultants sometimes talk of four stages of competence..." *gag*. While the Dreyfus references don't toggle that reflex.

If I could somehow say those things with a straight face and in an entertaining presentation, just think of all the money I could get as a management consultant.

"Deliberate practice"

The music, art, and crafts learning models are all built around practice. Lots and lots and lots of practice. Reflective practice, and with input from others in the field, including critical experts.

When doing the research for this write-up I came across the work of K. Anders Ericsson, known for his theory of "deliberate practice." It's theory I agree with. And cool - he's Swedish and is a professor at my alma mater, FSU.

The best page I found describing Ericsson's theory was a summary by David Zach Hambrick:

Expertise is commonly attributed to talent. According to Ericsson and Charness (1994), Vasari first articulated this view in his book The Lives of the Artist (1568). Much later, Galton argued that exceptional performance emerges from a confluence of innate ability and motivation. ...

Ericsson and colleagues reject the talent view. ...

The central claim of the deliberate practice framework is that exceptional performance reflects extended periods of intense training and preparation. ...

Ericsson et al. make a distinction between three types of domain-relevant experience: work, play, and deliberate practice. Only the latter activity provides optimal opportunities for performance improvement through feedback. In addition, unlike work and play, deliberate practice requires effort and does not lead to immediate reward.

There's also an article from CNN on Ericsson's "deliberate practice" theory. "What's the secret of success?" it asks. "Painful and demanding practice and hard work". Mmm, not sure about the "painful" part.

How do I get better in Swedish? I need to start practicing again. Deliberate practice, and not just talking to people during dancing. Oh, and yes, it can be quite painful. Mentally and emotionally trying.

Katas are practice

I think the idea of doing coding katas is a good thing. Practice helps. The kata examples Dave Thomas lists are pretty simple for me. In many cases I can remember doing the problem before, or know the answers from other elsewhere:

You get the idea. Or take this example based on bowling. We implemented that in my high school programming class. But I'm a much better coder now, and using a much better language and toolset than BASIC on an IBM PC.

When I was in school I participated in programming competitions. The most famous of these is the ACM International Collegiate Programming Contest, for universities. My high school came in first in the county but only sixth in the state. (First was a team we beat in the country.) In college we did okay, but the best team in Florida was from the University of Central Florida. They would regularly win or place in the regional competitions. Why? They practiced. They worked through problems from previous competitions. They practiced working in a team. And it helped. A lot.

Perhaps (and other have suggested this), some of the programming competition problems would make good kata problems. I wonder if I can come up with some good bio- or chemical- informatics ones.


Changed 22 August 2007: I attributed the "Herding Racehorses and Racing Sheep" idea to Dave Thomas when it's actually by Andy Hunt, who has an upcoming book on the topic.

Andrew Dalke is an independent consultant focusing on software development for computational chemistry and biology. Need contract programming, help, or training? Contact me

Copyright © 2001-2020 Andrew Dalke Scientific AB