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?

7
  • +1 to counter the unproductive -1 applied. Seems a valid question, as have my doubts about Code kata, but cannot pin point why.
    – mattnz
    Mar 6, 2012 at 9:19
  • 9
    until today I had no idea what this kata thing is about. Now I just checked it and imho it's just a fancy name for something that every sane programmer does and learns automatically while developping: practicing. So the drawback for me would be: it just takes extra time that could be used otherwise.
    – stijn
    Mar 6, 2012 at 11:01
  • 11
    Hmm … apparently, one major drawback of code kata seems the be that people are criticizing code kata without understanding what code kata are :-) Mar 6, 2012 at 11:56
  • 19
    @JörgWMittag - That's because the term 'kata' is a bad analogy since it implies the practice of rigid form with little practical meaning in real world situations. Applying martial arts words, like "black belt" or "kata", to programming or business situations irks me.
    – jfrankcarr
    Mar 6, 2012 at 12:15
  • 1

12 Answers 12

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.
1
  • 1
    I accepted this answer because it does address the question directly (instead of the "kata" terminology) and focuses on the potential problems of code kata practice. This is not to say that other answers are not good ones -- in fact, I would be happy to accept more than one! Mar 9, 2012 at 9:04
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.

6
  • 4
    Make that +2 for that sentence. Mar 6, 2012 at 16:46
  • 7
    While I agree that solving problems is a good way to improve as a programmer, learning to write elegant code can be a worthwhile pursuit as well. I wish that some of the original developers of code I currently maintain had put some time and effort into writing elegant code rather than copying and pasting to just get things to work. Mar 6, 2012 at 17:59
  • 2
    +3 for Mike's comment. In general, much more time is spent maintaining code than is spent initially writing it. You'd expect craftsmanship to be applied when someone builds your house, since you're going to live in it for a long time. The same should be applied when someone builds software -- but much of the time it is not. Sep 22, 2012 at 3:26
  • @KaptajnKold: Are you talking from your experience? I would love to hear some comments from someone who has really tried to improve his skills through CodeKata and failed.
    – dzieciou
    Nov 11, 2012 at 19:16
  • 2
    @dzieciou: I have experience in martial arts kata having practiced Karate for several years. And while I believe that there are some useful aspects of fighting that can be learned from kata, I also believe that it is ultimately not a very efficient way to train. You should train as you fight as they say. That is if your purpose is to become a better fighter. Some people find practicing kata to be a joyful pursuit in itself. There's nothing wrong with that. Eventually some of them become very good. At kata. Nov 14, 2012 at 11:18
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.

21
  • 10
    Is there any kind of learning that does not take time? Unless you are lucky enough to work on greenfield projects every time.
    – Den
    Mar 6, 2012 at 13:58
  • 39
    If you don't spent at least small amount of your free time to improve your programming skills on regular basis your professional career is in great danger. Mar 6, 2012 at 14:12
  • 8
    +1 to this. While I absolutely love programming, and that I'm able to earn money on something I love doing, I don't see the point in doing MORE programming outside of work. I have so many other hobbies (DJing, producing music, weight-lifting, drawing and street dance for instance) that I don't see the point on spending more hours on something I already do 40 hours / week. Mar 6, 2012 at 14:35
  • 8
    @mouviciel: And that is exactly the problem: your boss is willing to pay for your professional development, if it is needed on the project but you should be willing to improve your skills not related to your current project - maybe not related to your current platform at all. That is what builds your career / social security. Mar 6, 2012 at 15:05
  • 6
    @LadislavMrnka - I agree with you. Nevertheless, Code kata is not the answer to that problem.
    – mouviciel
    Mar 6, 2012 at 15:11
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.

9
  • spot on. fwiw, I am also a boxer/programmer :). Mar 6, 2012 at 14:55
  • 1
    Code katas are not about rigid repetition; they're more about working to solve a problem, then working to improve your solution until you're satisfied. From Kata One: "The goal of this kata is to practice a looser style of experimental modelling. Look for as many different ways of handling the issues as possible. Consider the various tradeoffs of each. What techniques use best for exploring these models? For recording them? How can you validate a model is reasonable?" Mar 6, 2012 at 18:59
  • 4
    I agree that the term 'kata' is imperfect, but don't lost sight of their point because of the name. Also, they're not all word problems; from Kata Two: "Implement a binary search routine (using the specification below) in the language and technique of your choice. Tomorrow, implement it again, using a totally different technique. Do the same the next day, until you have five totally unique implementations of a binary chop. (For example, one solution might be the traditional iterative approach, one might be recursive, one might use a functional style passing array slices around, and so on)." Mar 6, 2012 at 19:17
  • 3
    @MikePartridge That exemplifies my point. A kata would involve one method of binary search that each day is improved, say with fewer lines, or less time taken to write it from scratch. How a concept is described is important to define it. He could have just called it practice programming, which is what the articles are about, without bringing along incorrect baggage. The onus is on the author to pick words and concepts that correctly define his idea, not complain that his audience is pulling incorrect associations due to his choice of metaphor. Mar 6, 2012 at 19:36
  • 3
    @MikePartridge In my case, I believe all programmers are learning/improving, or should be, all the time. Thus, the code kata is a technique to assist in achieving this goal, and my answer was that the technique, as I saw it, was not worthwhile. I completely agree with the goal, but that wasn't the question. Mar 6, 2012 at 20:05
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.

7
  • 2
    Katas teach you new stuff. How can that be the opposite of what programmers aim to do? It’s also solving a puzzle, not something the majority of good programmers would perceive as “boring”. In fact, this is at the very heart of hacking. Mar 6, 2012 at 10:15
  • 5
    @KonradRudolph I thought repetition was the heart of the katas? So you would solve a problem once (new and exciting perhaps) but then you would keep on solving the same problem again and again. I've barely looked at Katas so I could be wrong.
    – Kevin D
    Mar 6, 2012 at 12:09
  • @Kevin I agree that this sounds stupid (unless you specifically try to find different ways of solving the problem). I’ve never done “katas” as such, just generic programming puzzles. Mar 6, 2012 at 12:43
  • How is doing the same thing over and over "teaching you new stuff"?
    – user7519
    Mar 6, 2012 at 18:03
  • It's clear in your answer that you didn't read the link provided in the question. Mar 6, 2012 at 18:29
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?

4
  • What if the thing you are practicing is redesign and improving design--repeating the design process, couldn't the term apply? Can you come up with a better one?
    – Bill K
    Mar 6, 2012 at 19:39
  • the term for redesigning and improving an existing system is refactoring ( Code refactoring is "disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior" ). They picked Kata because it sounds cool and mystical, without understanding the semantics.
    – user7519
    Mar 6, 2012 at 19:43
  • The term refactoring is a very different term from practicing to be good at refacotoring. Anyone can refactor code, that doesn't in any way imply that they do it well or are practiced at recognizing good refactoring opportunities. Although "Practicing Refactoring" is a descent term for it, it doesn't convey the dedication that Kata does so I think Kata may be a slightly better choice, although I am open to the theory that there is a better phrase out there yet.
    – Bill K
    Mar 6, 2012 at 22:01
  • 1
    Actually Gold Platting refers to "...additional or more polished features". What you describe seems more akin to Premature Optimization although after the fact. Mar 7, 2012 at 13:20
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.

3
  • Writing the same program over and over can be useful and interesting, e.g. if you do it using a different algorithm and/or in a different language every time. But probably it's not a kata.
    – 9000
    Mar 6, 2012 at 17:23
  • 2
    Read the link provided in the question; the idea is not mindless repetition as you seem to assume from the name. Mar 6, 2012 at 18:50
  • @9000 Actually that is exactly how I understand Code Katas. Often used when learning a new language, or trying a new approach to an already solved problem. Mar 7, 2012 at 13:22
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.

1
  • How did you find the guidance? I am struggling with same issue.
    – CodeYogi
    Dec 6, 2017 at 11:07
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...

6
  • 3
    coding != running 100 meter dash, unless that 100 meters is through a heavily wooded mine field one day and a land mine filled rice paddy the next day and a swamp filled with poisonous vipers the next day while under heavy sniper fire, see the pattern ... Kata is the wrong term semantically.
    – user7519
    Mar 6, 2012 at 17:54
  • 2
    -1 Training can happen on the job, even on paid time (not sure why people seem to forget this). Not everything is either pure work or pure learning. Mar 6, 2012 at 18:14
  • @JarrodRoberson the scenario you've just depicted is what a soldier does on a daily basis. So you picked a rather bad analogy. Frankly, I should be happy for people who do their 9-5 job then go home and stop learning as it gives me a competitive edge.
    – ThaDon
    Mar 6, 2012 at 19:11
  • 3
    Martin Fowler once was asked about spending money on training your employees "Aren't you afraid if you train them they will quit?", and his response was "No I am afraid if I don't train them they will stay!". Not every employer sees training as an expense, the good ones see it as an investment!
    – user7519
    Mar 6, 2012 at 19:15
  • Solving different difficult problems with little planning, experience or guidance is what most developers, especially junior developers have to do every day. I think it is a rather accurate analogy. 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 smarter people that don't need to study after work, and can learn everything the need and more in their 8 hours.
    – user7519
    Mar 6, 2012 at 19:19
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.

-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.

5
  • overly trained musicians in particular can be negatively pre-occupied by theoretical perfection, this is extremely dangerous to a career in software development. Music has an element of expression, programming software doesn't have this. You could argue Apple products have this expression, but that is design expression, the code is never seen or perceived directly. Music and Art are bad analogies for software development. And you show a marked prejudice against blue collar workers in that you assume they don't take any pride in their work or see value in quality.
    – user7519
    Mar 6, 2012 at 19:10
  • Don't mix training with practice. Overly trained is very different from overly practiced, and if you don't think the level of expression in your code is seen in delivery times and code stability, I don't really know if we have a common basis for discussion.
    – Bill K
    Mar 6, 2012 at 19:31
  • Doesn't matter what I think, I know that most customers won't recognized and care about carefully crafted code and how elegant it is crafted as long as the application sort of works most of the time. Same way that the majority of the population has never been concerned with sound and video quality of VHS and highly compressed internet video or cassette tapes and now highly compressed mp3s that remove all that nuance, without any complaints. Overly trained is worse than overly practiced, overly trained makes one ignore "good enough" and miserable in the software industry.
    – user7519
    Mar 6, 2012 at 19:37
  • Programming is a craft not an art. There are levels of craftsmanship and aesthetics to both, but art is not vocational in nature software development is vocational. More people make more money writing software than artists by a long shot. Software is not subjective, and doesn't exist solely for its own existence sake, paintings and music exist to please the creator more often than not as your definition of sellouts above implies as a differentiation. As someone who went to art university, I can tell you, programming is a vocational craft and nothing to do with creating a work of art.
    – user7519
    Mar 6, 2012 at 19:54
  • If you don't think well made software is delivered faster, less expensive and just plain better than software made by craftsmen, you haven't seen it done right. Not very unlikely, how many people have watched a master artist, musician or played with/against a pro sports player--they just aren't that common, and in our industry MUCH harder to recognize, but the difference in talent is the same as is the results. One artist can outperform 5 craftsmen in speed and quality, but few are lucky enough to have seen that so they don't believe it exists.
    – Bill K
    Mar 6, 2012 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.