Stupid Question 238-239: Should I do code Katas and what is a Kata?
[To celebrate my first year of programming I will ask a ‘stupid’ questions daily on my blog for a year, to make sure I learn at least 365 new things during my second year as a developer] [caption id=“attachment_7622” align=“aligncenter” width=“720”]What about a robot Kata? Best day in school :D (we didn’t do Katas with the robots, but would be fun to try)[/caption] I was introduced to Katas many years ago. When I was about 10 years old my mum took me to martial arts school, and I started learning karate. It turned out to be a horrible experience. Our teacher, master as he wanted us to call him, imagined himself living in a cruel world at war, and the only way we could survive was by mastering pain. And being the youngest person there I was the easiest one to bring to tears, and therefore all examples of pain had to be shown on me.
During the few years I did Karate I did a lot of Katas. I found them dreadfully boring and uninspiring, always awfully scared I would get out of sync and be punished. I swore never to do a Kata ever again, and started playing the guitar instead which was a step above Karate in coolness at the time.
In programming we like to find words that somewhat romanticize what we do, or maybe accurately portray the passion and love we have for the profession – depending on who you ask. ‘Kata’ is one of those words. It’s used to describe deliberate practice, but in contrast to the Kata done in Karate where automatizing and perfection is the goal, Kata in programming is used to describe a process where you practice finding better or alternate solutions by focusing one piece of logic at the time often in an iterative process. [caption id=“attachment_7612” align=“aligncenter” width=“720”]Fun at school[/caption] Not too long ago I decided to start doing Katas again, in code. I had gotten to a point where I had done so many hobby projects (my contribution to OSS), courses and tutorials I felt stuck and unable to focus. I was stuck in sense of learning. Since so many friends, and developers that I appreciate use them and recommend them, I decided to listen to their advice. So far my experience has been positive, and I’ve done one every other day for a few weeks, and I’ve learned more than I thought I would. I’ve done it before work or late at night, often before either working on an application at work or a hobby project at home. It somehow cleans my mind, and I find myself absorbed in those few lines of code with a rare sense of clarity. It has also tremendously helped me appreciate and understand TDD. Maybe it won’t last. Some swear by them, some dislike them. Why?
I want to have a fair discussion and do my best to present both sides, starting with the drawbacks. I’ll argue both sides, and all arguments as best as I can :) I realized today that my friend John Sonmez had written about the same topic,Why I don’t do Katas.Have read there as well!
Code Kata DrawBacks
Waste of time
There seems to be this picture of a person that *instead* of contributing to OSS, do projects, create online content and so on his spare time, will instead spend all time doing Katas until insanity kicks in. Or worse. He would charge clients to do this to work on his or her mastery. I doubt that describes the wast majority of Kata-devs out there, but good use of time is a valid argument. Its hard to say what is a better way to spend your time in regards to being a better programmer. It really depends on how you do the Katas, and why. If you deliberately look for new solutions and try out new languages, you can learn a lot. It won’t however replace what you would learn from actual projects. [caption id=“attachment_7632” align=“aligncenter” width=“695”]How I feel people view developers that like to do Katas :D[/caption] Form Over Function
Katas do not represent reality, and therefore not a solution applicable in a real project. I would agree on this, at the same time it is not the intent either. Sometimes coding Dojos and Katas are used on real projects to find a better solution, but it’s not usually how Katas are defined. Real projects are often rushed, there are people, logistics, and time. Having the time to quietly meditate over a piece of code and practice form can teach you about that – form. A skill that can be very good to have, but only when combined with other experience(s).
Katas Are A Hobby, And Programming Shouldn’t Be Your Hobby
Few people have said this to me. Probably because the devs I hang out with, online or in person aren’t the 8-5 people. They live and breathe – to some degree- programming. This argument can for any activity to improve programming skills, and I honestly believe you might struggle in the future getting a job, or the job you want, if you don’t put some effort on your own time. Mainly because work will limit what you can practice on, and if you want to change domain you need to acquire new skills. Few workplaces offer that, and many devs do this at home. But be smart about it, its not about the amount of time, its how it is spent.
Repetition Doesn’t Make You Better at It
While in many sports and professions repetition and practice is a core technique to improve, it’s hard to draw straight parallels to programming. If you do a Kata in its true meaning, repeating the same thing over and over again, then you will have small growth and then stop completely. But this goes for everything you do, you can force a similar implementation of an app with similar code and technologies and not learn much. But you can also, as with Katas, explore different solutions, different languages, see how others do it, and then see how that one piece can be applied to another project.
Katas Are Boring
Very subjective. I honestly enjoy doing them. Fully understand if you don’t. I might hate them in a year or two when the compiler (if one is used) turns into my Karate teacher :S [caption id=“attachment_7662” align=“aligncenter” width=“695”]Instructions are boring, for some. Some prefer to have them. Same goes for Katas, where others are bored, some find excitement and maybe feel they get the guidance they need to solve one thing before moving on and learning more[/caption]
The Positives
Great Introduction To TDD
TDD is something many developers are scared of, sometimes just the idea of unit testing. Spoonful’s in the form of a Kata is a good way to get started. Makes sense, and I agree- it sure worked for me. Doing a few Katas helped me embrace TDD, but it probably could have been done in a different way as well. It just happened to be that this was right for me.
Practicing Makes You Better
This depends on what you practice. The most important point is to know *what* you are practicing, and not believe that it can replace practicing in other ways. Make sure it is relevant to you, and what you do and that it has a future value as well (do the degree you can predict that of course).
Social Aspect
When done with others (Dojo) brings a social element to it, you get to do small scale code reviews and learn how other developers like to work. A great argument, but personally I’ve learned more from real projects as those tend to bring out emotions, complex problems and developers that I otherwise wouldn’t hang out with.
Perfect Warm Up
You will know aprox how long it will take, it won’t break anything, and nobody gets upset if you don’t finish it. But, if done in a hurry and done on auto, it would probably not yield anything.
Learning New Development Techniques/Workflows
Same as with TDD, it is a good way to get a gentle introduction to something new. When you have done a few you can compare them, and with the limited scope the comparison is easier (but of course not complete). A collection of Katas done on different techniques, languages, workflows and frameworks gives you a nice sampling for comparison. This is my favorite argument, and I learned this from Scott Allen. I believe he has a collection or two :)
Katas Are Fun
Subjective. I agree, many don’t.
To summarize a very long blog post that I now might refer to as an article (sound cooler doesn’t it?) here is my take on it, and this list is not finished, PLEASE do share your thoughts:
Katas can be a valuable way to improve your skills as a programmer, if:
- You enjoy them
- Have a purpose
- Try new angles, languages, improve the code, framework and so on
- You can compare and contrast results
- You can do this with others/discuss with others
- It’s not the only thing you do to improve (should be a smaller part of your development investment)
- Evaluation is done, and you can see that you have improved/ learned (keep a log, commit a log with each Kata when you push the code to wherever)
- You are scared to try TDD (or similar) and don’t know how to start
- You need to try a new technique to focus on one thing at the time
Katas will not work if:
- That is the only thing you do
- You just repeat the same steps
- There is hatred involved and you are crying throughout the process
- You believe the Katas are a replacement for complex problems and technical limitations
- A client is expected to pay (you can try, but it might be hard to sell)
- You believe you will become an expert at ___
Practical Advice (some)
- Collect them all in one place
- Compare and contrast solutions - and ask for feedback from other developers
- Try to use the end result in a project, or build on it
- Have purpose: Make a list of scenario, languages and frameworks or workflows you want to try
- Keep a log - just a few short sentences. What did you learn? Take a look at it a month or two later, have you benefited from that experience?
- Plan when and how long (aprox) to do a Kata, make sure it doesn’t absorb all your (free) time
And Katas – or the use of word Kata – will not give you cred with the elite developers, it will only sound cool to those that don’t quite know what it is or haven’t tried it. It’s just a word. Action is what counts, and therefore how you do them. Use the word to communicate a technique, as we have design patterns to name common solutions. And remember, never underestimate the value of working in a team, be that on a Kata or project. [caption id=“attachment_7642” align=“aligncenter” width=“960”]There is no replacement for team effort - share and compare Katas, or better, do them together. It might be a good fight ;)[/caption] I’ll keep doing my Katas, and thank you for all the recommendations on Twtter today, I have many new to try! Please share some thoughts on this, here are some tweets in regards to ‘kata or not to Kata:
I don’t think repeating the same kata over & over is beneficial, but as a training exercise on an irregular basis, definitely.
basketball analogy: practicing free throws is very different from a pickup game; both help you play better…
Katas are definitely not a waste of time. A great way to sharpen the saw, and also for introducing newbies to the joy of TDD.
I love to do them just to practise my programming skills
talking from an effective use of my time perspective…collaboration and reviews give me more feedback
I treat them as the warm up. When I want to make real things my mind is ready to go :)
Katas eliminate/ignore the things which make development tough: complexity, performance, scalability, etc
Among other benefits, pairing with a teammate over a kata can help in moving towards a consistent coding style as a team.
katas won’t help with technical problems like security boundaries for example…
I think they’re useful for a few reasons. Having a reason to approach same problem different ways is one of them.
Katas are great for trying out new languages (Rust) or new workflows (BDD). One always needs to sharpen your saw.
Comments
Thanks for explaining :-) I knew it wasn't a stupid question. I think these techniques help you gain new perspectives on old problems. Try building something that you created earlier, in a different language and try to use the best patterns that are available in that language. You may discover tricks that you can also use in the environment you originally built the solution in.
Last modified on 2013-09-11