The Ultimate Code Kata

Hi Jeff,

great post. It’s interesting to compare notes and tick off the bullet points. I’ve done most of the things from Peter’s list – good. I’ve done a few from Steve’s. What I’ve not done so far is write a blog. And I agree with your (implied) assessment: To write good code, it’s essential to write about code.

By the way: It’s nice to see someone outside of Microsoft using CodePlex.

Kenneth,

I would like to add that your work should be encouraging this type of activity and that much of your ‘practice’ should be done during “regular business hours” The most practice I do outside of work is an occasional project that catches my fancy (maybe a couple a year that take no more than a day or two to complete) and reading various trade magazines.

Thanks for this post. It’s relevant to things that have been swimming in my mind for a while.

There are two ways kata help you improve:

  • Doing new things. By studying a kata you’ve never studied before, you broaden your horizons. As a programmer, for example, you might write a simple HTTP server if you’ve never done network programming before (it might be worth me doing something like this, come to think of it).

  • Doing old things better. Even after you can do a “passing” kata, you can spend years improving it. A rough equivalent for programmers would be “pimping my code,” as Wil Shipley calls it. IMO you’ve got to be constantly pimping.

The kata metaphor breaks down a bit in that in martial arts, kata tend to be traditional with very little room for variation and no room for invention. By contrast, when you’re doing coding-for-exercise, it’s a good thing to invent new little projects. I think of them like a musician writing etudes to work on a particular aspect of technique.

By the way, I practice judo, where kata play a somewhat different role than in karate, but the general idea is the same.

This was a great post. Thanks!

I think actual program practice also helps in other ways you develop lots of code snippets you can then refer back to when you can’t remember exactly how to do something. I still have all the lab exercises from when I did my MCAD sometimes open them just to find a simple bit of code. I think lots of programmers either keep all the source to all their projects for ever even if they change programming languages, other people prefer a proper code repository.

I have usually disagreed with much of what is on here in the past, but I think he is right on in this text. I as a programmer, do quite a bit outside work to keep my skills honed. I involve myself with open source projects in diverse languages and environments, just to keep me on my toes. I go to programmer user groups, and even speak and give presentations occasionally. and after work whilst most programmers are staying as far away from code as they can while they relax, I’m in front of my computer making up stupid things to code. I mean, really stupid things… but just to code. like I wrote a program that would scan my hard drives for all images on the system, and display it out paginated in a Windows.Form.WebBrowser control. Why? absolutely no reason, but just to do some coding.

Great article. I had to read code for two months once and it was a BIG experience. Still have my doubts about the blog, though.

There are some comments with bad karma here, but as don Quixote said: ‘the dogs bark: a sign that we’re riding, Sancho’

best regards

Noticed something similar just the other day while driving out to the airport… There’s an awful lot of people that have never progressed beyond the most basic driving skills that they learned eons ago…

2 kenneth the thing is, if you don’t enjoy (as much) coding in your free time, you don’t get as much practice as those people who do.

programming professionally can leave you feeling burnt-out (doing almost the same full time, in “a standard language” is no fun), so no joyful coding (ie. expanding your own horizons) afterwards for you.

no, programming professionally has nothing to do with being a good programmer, other than bringing false sense of being one.

i know a buch of “professional programmers” who just use patterns they learned in some book/from somebody else and in case they don’t know they just cutpaste some code from web without fully understanding it (it works, so what) …

so IMO no, unless one enjoys coding in his free time (and tries his best to understand everything, likes to take it apart to see how it ticks …), no, one can’t be a good programmer.

I once wrote on my blog about the need to study by comparing how experience and purposeful education teach us differently.

http://www.daltonfilho.com/2008/02/10/in-praise-of-education/

I like this kata idea exactly because software is more about people: if we can find a way to study efficiently, it means there will be more free time to do other fulfilling things, which, on their turn, will make us happier (and therefore better) programmers.

This reminds of a dinosaur comic that i think summarizes the post nicely.

FRIGGIN’ INTENSE!!

Re: Write a blog: http://softwareindustrialization.com

Re: Actively participate in a notable open source project or three: Well, maybe not notable: http://globalsystembuilder.com

So, what does it all mean?

Jeff, you should include a “code katas” section here or on stackoverflow. Give us some practice exercises to try, a mix of coding problems (fizz buzz anyone? !!), general thinking problems, etc.

If some of the people who commented on this post are programmers, then we have a problem.Some read just one line and then go commenting based on that line.I think its a great post, and Jeff is a great programmer.(see his articles on codeproject)Great insight.Cheers

@ak47

While I’m not for copying code from the internet and pasting it into my software, why should a “good programmer” really understand how everything works underneath the code?

From my perspective, I’m more interested in writing programs that solve problems for myself and others. I’m not too interested in just how exactly my code writes to the hard drive, or when I call MessageBox.Show() what is done behind the scenes to draw the little popup, etc… etc…

I see a lot of people with the same mentality of “good programmers” devote all their time to learning C or trying their best to write the fastest sorting routine ever… but I have to wonder where the “problem solving programmers” mix into the sterotypical “good programmer”.

Fantastic post, as usual, Sensei. You even inspired a blog tribute to some heroes of mine:

http://tech.puredanger.com/2008/06/23/on-code-bird-and-coltrane

HB - anyone can write ordinary business apps. Good programmers are capable of expanding far beyond this domain, which requires a deeper knowledge of how your platform works. Try designing 3d modeling software, or optical-character-recognition software to learn about neural nets, or a video game with a computer opponent so you can practice AI, or maybe design a small programming language (I recently wrote an interpreter for a prolog-style language in Python). Software development is not simply about solving today’s business problems, it’s about exploring the potential of computer science to solve truely unique problems and accomplish something spectacular.

@KB

LOL! Well mark me down as one more “adaquate” programmer. It’s fun – but I get the burnout thing when I get home so I’d rather get away from the keyboard.

@KG

I started off programming by writing little scripting languages, and I’m sure a lot of other did too. To be a good programmer doesn’t require a low-level knowledge of the platform, or even a high level knowledge. Any amount of problem solving is practice. Unless I’m interested in 3d modeling or OCR, why would I try to do it. My “truly unique problems” I deal with every day are usually accounting based. All the physics knowledge in the world won’t help you manage financial software.