Code Kata
Can You Be a Ninja?
After many years working for different companies on different applications, I’ve seen a lot of techniques that claim to help developers improve their programming skills. Unfortunately, only a few really helped me out at all, not only improving myself, but also teaching others.
Some of you may know Dave Thomas, or at least have heard about the “DRY” (Don’t Repeat Yourself) concept or other concepts that he coined. He is a computer programmer and author/editor. One of his most famous books is The Pragmatic Programmer, a book about software engineering published in 1999.
Once the Ruby expansion started, Dave Thomas became one of its biggest evangelists, he wrote a lot about the philosophy and market context behind the origin of Ruby and Rails. It end up leading him to learn a lot about agile techniques and concepts. It is here that he coined the term Code Katas as a development learning technique and started to spread it.
Katas from Martial Arts
The term Kata originally comes from martial arts: it’s the Japanese translation of the word form. Kata is used to describe detailed, choreographed patterns of movement that can be practiced either solo or in pairs.
It can describe other actions in martial arts, as you can see on Wikipedia, like training, high detailed simulated combats, and others.
Kata originally were teaching and training methods by which successful combat techniques were preserved and passed on. Practicing kata allowed a company of persons to engage in a struggle using a systematic approach, rather than as individuals in a disorderly manner.
The main goal of using Katas in martial arts is transmitting proven techniques and practicing them in a repetitive manner. This leads the learner to develop the ability to execute those techniques and movements in a natural, reflex-like manner. In order to achieve this goal, the key isn’t to do this systematically, rather internalizing the movements and techniques, so you can adapt those techniques to different needs.
Practicing
Practicing as a learning method is ubiquitous. We can see it in many areas, not only martial arts:
- Playing a musical instrument
- Improving one’s performance in sports
- Preparing for public speaking
- Improving one’s grammar and spelling
It already has proven itself as a fundamental learning method. Of course, it depends on many factors, but with the right guidance and dedication, you can master a lot of things by practice. This affirmation is the basis of what is called Procedural Memory.
Procedural Memory
Procedural memory is a type of long-term memory, specifically, it is a type of implicit memory that can be used for Procedural Learning. This is achieved by repetition of the same complex task, resulting in an enhancement of the neural systems used to accomplish that task.
Psychologists started to write about Procedural Memory over a century ago. It was first noted in 1804 by Maine de Biran. After much research, it was proven that merely repeating a task alone does not ensure the acquisition of a skill. Behavior must change as a result of the repetition. If the behavior change is observed, then you can claim to have acquired the new skill.
Code Katas
The How
Dave Thomas concluded that it’s possible to use Katas as a learning technique in programming. The approach is really simple: a code kata is a simple coding problem intended to be easily solved, that you solve again and again, repeated to perfection. The idea is to help you to solve the problem in a better way every time you try, while your subconscious learns detailed problem/solution pairs that might help you in other problems. You can even do this by challenging yourself with limitations, such as the use of a language other than the one you use daily.
How Not to Kata
A lot of people think that Code Katas are about solving only the same problem in the same way. This will lead you to learn nothing, but only teach you shortcuts in your IDE. As I said before about procedural memory:
…merely repeating a task alone does not ensure the acquisition of a skill. Behavior must change as a result of the repetition.
As Jonh Sonmez says in this blog post:
just as walking every single day doesn’t make you a master walker, and driving a car every day doesn’t make you a superior driver, solving the same sets of programming problems over and over again won’t make you a master programmer.
…
Repeating the same thing over and over again without an increasing level of challenge actually results in the mind becoming complacent with the activity.
If you want to use Code Katas, it must be challenging, as walking was when you were just a baby, as driving was when you were just an teenager. Repetition won’t help you if your brain is not engaged.
You must challenge your brain so you can exercise your neural pathways and create new ones. Writing the same code over and over again in your IDE will only make you more comfortable with it.
Where to find it
Unfortunately, the original Code Katas website made by Dave Thomas is offline, but there are plenty of other websites with code katas, challenges, and information. As a Ruby developer I’d recommend:
- CodeKatas.org – Codekatas.org is intended to be the go-to place when you’re looking for Code Katas, whether you want to watch someone else perform or start practicing yourself.
- Coders Dojo – A great list of katas in many languages. It also has a web client in Ruby to perform katas online, along with many examples in their catalog.
Learning
Many people ask me how they can learn to develop iOS apps, Android apps, single page apps, or any other technology related to programming. The answer is simple: make those apps.
“But, what post or book should I read about building those apps?” Forget about books for now: just start putting your idea on paper and begin the development process. Learn and do at the same time.
Raising the Bar
The reality is, there is no silver bullet. But there are a lot of techniques out there, and if you really want to improve your programming skills, Code Katas is one of those techniques. You don’t have to fall in love with it, just give it a chance.
The truth is, if you want a different outcome, you have to change something.