Refactoring
to
maintainability

Two or more ...


Return to Index

Katas

2020-02-17

I think I started with the ideas of katas through the Dave Thomas website. Since then, I have done a few, I have used them during interviews, run the LSCC Coding Dojo meetups and even created one of my own (I needed a slightly christmas themed kata last December)

Why Katas?

I think Thomas’ original vision that we needed some practice, deliberate practice is still valid. Most times we just have to fly coding at work, doing meetings and what else. At home we sometimes do practice, but my own experience and what I have gathered through talking with other people, is that the deliberate part to improve our craft is not there. The Object calisthenics fall into the same area, and this lack of deliberate practice is something that tripped me off the first time I went to do a production FP project (which is why we looked into Functional Calisthenics). Deliberate practice is very much needed.

The Point of a Kata

How many have you tried? What do you think is the most important part of each of those katas?

I think katas must have a point. There must be something that makes them worthwhile to do (and redo). The Tenis kata is about handling of the funky scoring, the Mars Rover around those multiple versions of each instruction you can give to the rover, the Bank kata is about the “printing” of the statement with the running total. A kata without a point is just some uninteresting random code.

When To Practice Katas?

Whenever you have half hour or one hour, and you don’t want to get involved with a bigger piece of code. Maybe during commuting, or while chilling out at home after a hard day at work. After the kids have gone to sleep.

How To Practice

One of the greatest things about katas is that there is no deadline. No rush to get it out of the door because the stakeholders require it. It is all about deliberate practice. Think ahead. Do some TDD (nearly all katas are superb to get to the ropes of TDD)

There is no point on just going through all the different katas (and there are a few), once and never come back to them. You will miss most of the benefits of katas. You do them, and come back again to do them again, and again.

But repetition for repetition’s sake is not useful either. Each time that you repeat them you change your approach slightly. Maybe you change the number of constructs that you use; Maybe their relationship is different; Maybe the algorithm is different; Maybe is time to try it in another language (especially different paradigm), and see how the solution changes. Maybe you can find a solution that is superior to others. But don’t stop trying different approaches. See what works and doesn’t. How your name changes affect your understanding of the code. Compare different algorithms tradeoffs. See that different paradigms force you to look at the problem on a new light.

Once at University there was this exercise that we needed to do. It was done with around 20 lines of M68000 assembly. I did it four times, each time changing how I resolved it, and learning a bit about how to handle operations within the assembly language. I have done multiple times the bank kata: sometimes I have a printer construct, sometimes not; sometimes I leave the reverse ordering for printing time, sometimes I do it when I store the data; sometimes I have a running total with the stored data, sometimes I calculate it on print. There are options, multiple options. Investigate them all, try them all.

Alternatives?

Are there alternatives to katas. Yes and No. I don’t think there is anything at the moment that is so useful for discovery on the small. There are alternatives, because you can get to the knowledge through other means. Pair Programming with an experience developer is probably a good way to get the knowledge, and is an alternative that can be done within your normal work. If there is much difference between the pair, it becomes pure transfer of knowhow. If the pair is more equilibrated, you can easily discuss different solutions as you go along.

Departing Words

Can you become a good programmer without doing Katas? Of course you can. But, like with everything else, deliberate continuous practice makes you go much faster than just relying exclusively on what you do at work. The feedback loop is much shorter, and therefore you learn the lessons much earlier.


Return to Index

Unless otherwise stated, all posts are my own and not associated with any other particular person or company.

For all code - MIT license
All other text - Creative Commons Attribution-ShareAlike 4.0 International License
Creative Commons BY-SA license image