Main | Kata Twenty One: Simple Lists »

January 28, 2007

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d83451c41c69e200d834de8bcd53ef

Listed below are links to weblogs that reference Code Kata:

» Cold Hashes from Pawprints of the Mind
So I've been reading about practicing programming, and in particular, Dave Thomas' Code Kata. In Kata Ten, he asks about a design question: hashes versus classes. Can hashes and classes be interchanged? Do you really want to? There's even a specific co [Read More]

Comments

ToLGaDrifT

I'm a Mac nerd and a Unix sysadmin by profession and there's a couple of things I'd like to say here.

Firstly, pretty much every command I have seen in the cheatsheets I looked at will work on a Mac. Mac OS X has a very pretty GUI but the power and precision is there hiding underneath as soon as you need it.

Secondly, you don't need reams of cheatsheets to perform simple tasks. The tasks that most of the people I work with use would fit on half a sheet of paper and you wouldn't have to use the sheet after an hour's usage. Complex tasks, on the other hand, are a different matter. I was trying to think of something you can't do in the GUI and, thanks to spotlight, there really isn't very much left.

The two things I came up with highlight the main two reasons for using the command line: precision and power.

With spotlight, I could find references to a particular image in all the html files in my website and open them up for editing. With BBEdit, I could do the same thing but automatically change the image name to its new name. But with a command line I can find all references to this image that are not already wrapped in a link and change both the image to be its thumbnail version and the link to point to the full-sized version or I can add a new link all in one command.

The second is a task that I had to perform last week and would have taken me all week in a GUI. Someone (or a piece of malfunctioning software) had deleted a few of the original sized images from a gallery but left the mid-sized images, the thumbnails and all the references to the missing files in place. I wrote a command that would print out a list of all the missing filenames and I can't think of a way of doing that in a GUI that would be quicker than several hours.

The greatest power of the command line is in chaining commands together. Practically every day I end up analysing an Apache log file, looking for some pattern that could explain what is happening. Sometimes I want to find the IP addressses with the most requests (cut -d' ' -f1 access_log | sort | uniq -c | sort -n) or I want to find all of the pages that returned 304 response codes (awk '$9 ~ /304/ {print $7}' access_log | sort | uniq) or I want to add up all of the bandwidth used by various different pages and list the top twenty (for PAGE in `cut -d' ' -f7 access_log | sort | uniq`; do awk -v PAGE=$PAGE 'BEGIN {SUM=0} $7 ~ /PAGE/ {SUM=SUM $10} END {PRINT SUM,PAGE}'; done | sort -n | head -20)

Erik Nilsson

Hi!

Thanks for the excersises!

You compare programmers to musicians and that makes me think about Hanon excersises. I think that coding Katas are pretty similar to these.

The Hanon excersises are a set of 60 excersises for the piano to train some difficult fingering techniques. They are to be repeated daily to retain technique. They were created by Charles-Louis Hanon.

Hanon excersises have received quite a lot of criticism. It includes "doing drills repeatedly will make your attitude towards music mechanical", "it's just boring", "even when you've mastered all 60 you still haven't performed one actual piece of music" etc.

Now I'm not saying that's automatically true for code Katas but it would be interesting to hear your comments on some questions that come to mind:

Why is it important to do these drills? What skills do they add to your repertoar? After doing all your Katas, will you be able to write good programs? Is coding Katas anything like Hanon excersises do you think?

You say that musicians repeatedly practice but you should now that successful musicians also take great care practicing the right things. There is no end to the amount of time you can spend practicing things mindlessly. More on that in this book: http://www.pianofundamentals.com/ which has some interesting ideas about how to practice the piano. Wikipedia has an article about the Hanon excersises: http://en.wikipedia.org/wiki/The_Virtuoso_Pianist_in_60_Exercises

I very much like to hear you elaborate on the Katas and how to use them properly, I find the subject very interesting.

Chen Shuiyang

I am knowing kata now~thanks!

travesti

Thnks;
This should be a training for programmers...

Dave Thomas

Todd: Thanks! Fixed.

Todd Fiske

You're missing the word "from" in the fourth sentence: "But ultimately, greatness comes [from] practicing;"

I realize the post is now nearly three years old, but it's never too late to improve quality, right? =)

ajmCafe

Been a programmer (in one form or another) since days with TI/40A and Apple IIe. But the Prag folks and, now, your blog is helping to revive the joy in this craft. Thanks!

L Pedersen

I agree with Ivan Dolvich and I checked out the PragProg wiki for help about discussed answers but I found nothing. Could you please point me in the right direction so I can extend to beyond the basics and learn from the honored sensei's of this discipline.

Thanks.

MMA

If you want the ultimate code kata then do the exercises in SICP ... all of them 'nuff said.

Wiliam

Hey man, thanks for the katas, it's a really good idea! Congratulations!

jiejie

i love karatedo. Phil.

jiejie

i love karatedo. Phil.

Ivan Dolvich

Dave, I've been looking for exercises like these for a long time, and am happy to find your site. But why are there no answers like on RubyQuiz? I think one can benefit very much from learning from the others. Without other solutions to compare there are several disadvantages:

* solving problems "alone" is no fun
* you don't know how good your solution is until you compare it
* you don't get different ideas

This should be a training for programmers. When I were a white belt in BJJ, some fellow blue belts showed me so many things. I think this would add much value to this site.

Max Williams

haha, i forgot exam rule #1 - always read to the end of the question before starting to answer.

Dave Thomas

Max:

Have a look at the last three paragraphs of this blog entry....

Max Williams

Hi Dave, thanks for the kata site and the great books.

It feels like there should be a forum for sharing, comparison and discussion of solutions to these and other kata. Do you know of such a site? (my simple google didn't throw anything useful up)

Dave Thomas

I have to disagree with the first part of your sentence: the Kata are most definitely not taken from another source, except where credited. If there is overlap, it is a coincidence—some problems are fairly universal.

I agree with the second part, though—Programming Pearls and it's successor are indeed good books.

Dimitar Dimitrov

Most if not all of the katas are from the excellent book
"Programming Pearls" by John Bentley
http://www.cs.bell-labs.com/cm/cs/pearls/

Dave Thomas

Thanks--got it fixed.

George

Your link to MoreKata (http://pragdave.blogs.pragprog.com/Practices/MoreKata.rdoc) throws a 404. And thanks for the resource.

Dave Thomas

Thanks for pointing that out. It's there now.

James

Hi,

It seems that "15. Playing With Bits" was not transferred across. When you click on the link it returns page not found and the navigation from kata to kata skips over it as well (14 to 16).

Thanks.

James....

The comments to this entry are closed.