42

Code kata is a concept that proposes to hone programmer's skill by doing small problems many times trying to improve the code at each iteration. The name comes from an analogy to martial art kata where forms (aka kata) are practices done over and over leading to improvements.

From the reaction I got to my last question on the topic, I wish to know what are the draw backs of this approach?

12 Answers12

44

I think programming kata, like martial arts kata, is mainly about form over function. It may teach you to write elegant code, but it will not teach you to solve the problems you are writing the code for. I think a better way to improve as a programmer is to solve puzzles that require actual problem solving, and to work on larger projects that will teach you the value of well-factored code in a way that code kata can never teach you.

As an aside, I think terms like 'code kata' and 'software craftsmanship' are more about romanticizing our profession than they are about describing anything novel or useful.

Zack
  • 3
23

In principle, I don't see drawbacks in code kata. You try to accomplish the same task many times, with different approaches and different languages. But

  1. it is rather difficult to introduce it in a work place. You are usually expected to be proficient or reasonably productive. I am not saying it would not be useful (better to spend some time to improve the skills of a new hire than to pay for the not so good code he will write in the time to come) but it is rather difficult none the less.
  2. you must actuallu try to improve in some sense. Writing the same code in the same way one thousand times will not make you improve (rather it will dull you). You must understand your previous errors, what went wrong or not worked out as expected. This is the most important part. It is a form of self study, so you must study.
Francesco
  • 1,416
  • 14
  • 22
20

Code kata just takes time.

Being full time developer and father, I don't want to make computing a hobby.

And I don't imagine that my boss would pay me to develop applications unrelated to my current project.

mouviciel
  • 15,491
13

As a boxer, I'd have to disagree with the principle behind the kata. It's too rigid to be actually useful. In the ring, you have to understand how to apply the principles you have learned in a free flowing environment.

This is not to say that learning and improving of the technique should not be done. Practicing on the bags allows you to work through a using a punch and feeling how you throw it, the same as a kata. But it isn't as rigid. You are practicing many things at the same time, moving around the bag, throwing from a stable platform, aiming, breathing, the list goes on.

Most importantly, everything is learned together the way it will actually be used. If you can write the most beautiful for loop ever, but you can't understand how to fit it into a program, then what good is it?

I would say that a better thing to do if you want practice would be building yourself tools, or working on tools you use. It requires exercising all of your skills and in the end you may have something useful.

12

From my perspective the main drawback is that it would be horrendously boring. Also programmers seem to thrive on developing software that does something useful or cool. The code kata approach would seem to be the opposite of that.

Antonio2011a
  • 1,209
8

Kata means the exact opposite of what you should be striving for.

an exercise consisting of a sequence of the specific movements of a martial art, used in training and designed to show skill in technique

The term Kata ( Origin: 1950–55; < Japanese: shape, pattern ) as used in martial arts, and your question are about rote memorization of muscle memory like touch typing .

In the original Karate Kid, waxing the cars, sanding the floors, painting the fence these were all Katas that were taught, completely out of context and in this case without explanation just to provide muscle memory. It wasn't until a sensei came in and gave these hollow activities context that they meant anything.

I think the same thing applies here, without a mentor to put things in context re-doing problem solving wrong in multiple languages is no better than a single one. Without the mentor to tell you where to improve they are a waste of time.

It is the exact opposite of creatively solving problems by learning new variations of idioms and semantics of a language or platform.

If you want to be able to type System.out.println() as effortlessly as possible, then practicing that would be a Kata.

If you want to improve a solution to a problem in a different implementation, to reduce time and/or space requirements or apply more idiomatic principles, that isn not something that Kata will help you with.

There is already an accepted industry term for re-implementing the same thing over and over after it already works striving for small incremental improvements and questionable benefits of perfection, it is called Gold Plating!

The terms they should have used are Refactoring when applied to the same language/runtime/platform. And Porting when moving a working program to a different language/runtime/platform. Kata was probably erronously chosen because it sounds hipster, cool and mystical without completely understanding the semantics.

Solving different difficult problems with little planning, experience or guidance is what most developers, especially junior developers have to do every day.

Only academics get to do the same exercise over and over just for the sake of honing a specific solution. The skill in having a successful career as a developer is in adaptation, not repetition.

Who says that there aren't smart people that don't need to study after work, and can learn everything the need to know and sometimes more in their 8 hours at work?

5

I agree that the metaphor "kata" may not be the best. A kata in karate is performed for the purpose of practicing a specific, discrete movement until it can be performed flawlessly, crisply, and automatically. This does not translate well to an activity where critical thinking and creativity are required. (It would translate better to, say, typing).

That said, the failing of the name is not a failing of the activity. What possible drawback could there be to practicing something at which someone wants to get better? I suppose one could say that the time spent doing it is a drawback, from an opportunity cost perspective, but really, it's an investment. So, the time spent practicing the craft of software development is to software developers as the money spent on equities or bonds is to a long term saver/investor. It's not a 'drawback' -- it's table stakes.

3

You get better by trying things that are difficult and just out of reach of your abilities; challenging yourself. Doing the same "code kata" over and over, like a martial arts form, doesn't do that. I think it stagnates your abilities instead of helping to push your skills forward.

It has its use as a method of practice the first time, but it is limited. I tell people to use project Euler instead. More problems and more challenging.

jmq
  • 6,108
3

To me, the main drawback of the technique as I see it is its sub-optimal use of your time.

The learning value of this exercise is also questionable: when you do something over an over to get better at it, expert feedback is essential. Without high-quality feedback you will learn something too, but there is a chance of learning a wrong thing very well.

Don't get me wrong, practicing remains the only way of becoming good at programming, and kata is most definitely a form of practice. But so is solving coding competition problems, writing your own "fun projects", learning new programming languages, and so on. Ultimately, you need to choose the technique with which you are most comfortable, and make sure that you have clear guidance along the way.

2

I believe without some form of Kata you'll never be a great coder. Kata is practice, that's literally what it means. Take this as an example: An athlete says "I'll just show up and run the 100 meter dash, screw practice". Does that sound like a winning strategy? Is it ever done this way?

I suggest people Read Uncle Bob's "The Clean Coder", he goes in depth on this (and other) topics of professionalism in the field of programming.

Oh and arguments put forth that you can't do Kata and raise a family are simply excuses. Speaking from experience: kids go to sleep at some point...

ThaDon
  • 236
1

Doing only katas, in a martial art context, is useless. As said before, katas are choregraphy of movements that teaches you the form. You know the movements but you don't know how to apply them. You don't know in which situations they are useful. If you really want to do something useful with them, you need the application(s), which is the Bunkai.

In a software context, the code kata would be the algorithm, tool, design pattern or any other technology. Knowing it is good, but you need to apply it to understand it. You need to use it in different contexts to really master it. The Bunkai would be a concrete situation where that kata or part of kata is useful.

I don't see anything wrong with that methodology, this is how about anything is mastered: learn something, practice it, add a detail, practice, add another detail, practice, etc.

plmaheu
  • 173
  • 6
-1

Programming is an art--like painting or music. When someone becomes a musician or artist for money you can tell, there is no inspiration, the performance is not really worth your time. If you are into the art, nothing can stop you from practicing and constantly refining it--every day refining a single technique, noticing the nuances that most people will never see.

There is always room for people happy being bar musicians and house painters, but they are a completely different class of talent. I suppose that most house painters would laugh at the idea of practicing, but I bet a painter that did research and practiced techniques--essentially recognizing their job as an art would do a noticeably better job, even on something as mundane as painting your house.

Some people will recognize the value of practice some wont. That alone should be of value if you are in the position to evaluate and you are looking for people who can make art (lean, simple, understandable code) and not just a solution.

ps. I'm not calling myself awesomely artistic or anything--I don't do Kata on abstract problems but I recognize the value and I do try to refactor my production code quite a bit.

Bill K
  • 2,749