EDITING BOARD
RO
EN
×
▼ BROWSE ISSUES ▼
Issue 23

Code Kata

Tudor Trișcă
Team Lead & Scrum Master
@.msg systems Romania



PROGRAMMING

The word Kata comes from martial arts: it is the Japanese translation of the word form. Kata is used to describe detailed, choreographed patterns of movement that can be practiced either alone or in pairs.

It can also describe other actions from martial arts like: training, highly detailed simulated combats, and others.

Katas were learning and teaching methods through which successful combat techniques were preserved and passed on. Practicing Kata allowed a group of persons to engage in combat using a systematic approach, rather than as individuals in a chaotic manner.

The main goal of using Katas in martial arts is transmitting proven techniques and practicing them in a repetitive way. This helps the learner to develop the ability to execute these techniques and movements in a natural way, just like a reflex. For reaching this level, the idea is not to do this systematically, but internalizing the movements and techniques, so that the person can adapt these techniques to different needs.

Practicing

Practicing as a learning method is ubiquitous. There are many areas in which it can be applied, not only martial arts:

  • Playing a musical instrument
  • Improving one"s performance in sports
  • Preparing for public speaking, and others.

It has already proven itself as a fundamental learning method. Of course, it depends on many factors, but with the right guidance and dedication, a person can master a lot of things by practice.

Procedural Memory

Procedural memory is a type of long-time memory, more specific, is the type of memory that can be used for techniques 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. After a lot of 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 one can say that the new skill was acquired.

Code Kata

Dave Thomas was the first to introduce the idea of 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 the programmer solve the given problem in a better way with every attempt, while the subconscious learns detailed problem/solution pairs that might help in other problems. Katas can also be done by adding other challenges like some limitations, such as the use of a programming language other than the one used daily. A Kata can be done either by one programmer, or in an organized group.

Work is not practice

Work can bring too much pressure on the inexperienced programmers: putting pressure on the need to deliver quality code using unfamiliar techniques; this can lead to frustrations, mistakes or failure to apply best practices. There is not always enough support from mentors: the experienced programmers are often busy with finishing their assigned task and do not find the necessary time needed to help others grow.

Becoming a better programmer is about practice. How good would a music band be if they only practiced while they were on stage? What kind of quality would a play have if the actors were only given the script an hour before the show?

How not to Code Kata

A lot of people think that Code Katas are about solving only the same problems in the same way. This will lead probably only to learning new shortcuts in the IDE used. As I previously mentioned 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.

Just as walking each day does not make you a master walker, and driving a car every day does not make you a superior driver, solving the same sets of programming problems over and over again will not 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 do Code Katas, they must be challenging. Repetition will not help if the brain is not engaged.

The brain must be challenged in order to exercise and create new neural pathways.

Tips & Tricks

Pair-programming: team work is a key factor in the Code Kata sessions. It should enable learning to occur during implementation because the programmer not at the keyboard is observing, commenting and questioning, providing continuous feedback (but not dictating, criticizing or controlling).

Completion must not be enforced: If there is too much emphasis on completing the task, programmers will start to sacrifice quality. This thing happens in production environments when too much pressure is placed on velocity over quality. If the aim for the session is to speed programmers up, they must be allowed to practice without feeling the pressure of completing the task within a set timeframe. In time it can be observed that the programming techniques become a second nature and the end result will be faster development and higher quality code.

Inurement that at the end of the session the code is deleted: The idea to start with is that there are always multiple ways of solving the same problem and that is especially true for programming. If you ask ten programmers to solve a certain problem, most likely there will be ten different implementations. But which one is the best? Probably none of them, potentially a combination of some (or all) implementations, or maybe a totally different solution. The point is that it is good for the programmers to understand there is more than one way of doing something and that throwing away the code and starting again is sometimes the best option.

Helping pairs to contribute equally: The programming pairs that participate in the session must be observed and helped to treat each other as equals. It is often difficult when there is a pair consisting of a senior and a junior but it is important that this is about both contributing equally. This is not a mentoring session.

Strictness of time: From time to time, the trend will be to give a bit more time for developing. But this is because too much emphasis is being placed on task completion which must not be a priority. The programmers must be re-assured that it is not about completion; once they understand this, they will stop asking for more time.

Keeping the session fun, but intense: Background music never hurts (but it should not be a distraction), discussions must be initiated, rewards provided, whatever is needed to stimulate the programmers. The focus must be on removing anxieties and reassuring that making mistakes and failing is good.

Communication encouragement: The room where the session is being held should always be buzzing with discussions, ideas, but all the time highly focused on the task. If the room is quiet and people are disengaging from the process, then something is wrong.

Finding challenging Code Katas, but not out of reach: The mistake of choosing a highly complex task for the session should not be made, because the enthusiasm will fall and the programmers will disengage from the process.

Conclusion

The idea to start with when you want to initiate or to participate to a Code Kata session is the fact that the point of a Kata is not arriving at a correct answer. All that matters is the knowledge you gain along the way. The goal is the practice, not the solution.

References:

"Code Katas", Bart Bakker, 2014

"Code Kata", Joao M. D. Moura, 2014

"Using Code Kata practice sessions to become a better developer", Kirsten, UVd, 2013

"Performing Code Katas", Micah Martin, Kelly Steensma, 2013

"Why I Don"t Do Code Katas" John Sonmez, 2013

"Code Katas: Practicing Your Craft", 2011

"Code Kata - Improve your skills thrugh deliberate practice", 2013

VIDEO: ISSUE 109 LAUNCH EVENT

Sponsors

  • Accenture
  • BT Code Crafters
  • Accesa
  • Bosch
  • Betfair
  • MHP
  • BoatyardX
  • .msg systems
  • P3 group
  • Ing Hubs
  • Cognizant Softvision
  • Colors in projects

VIDEO: ISSUE 109 LAUNCH EVENT