“Practice makes perfect” is an old adage that implies that one can get better at a skill through repeated practice. In addition, there have been studies conducted that state that deliberate practice helps improve skill. The word “kata” is a martial arts term that means to repeat a form time and time again. Through repetition, you’re able to make small improvements every time. Code katas are exercises that bring this approach to honing your development skills. Though there are differing views on what constitutes a Code Kata, I’ll take the broad view of the term here to mean anything from coding a simple algorithm to implementing a complete properly architected system for fun in your spare time.
There is plenty written on the topic of building Code Katas into your routine. Here are four ways in which I’ve found the experience of using Code Katas as a means of deliberate practice to be particularly useful.
Let’s begin at the beginning…
As developers, we end up extending and maintaining code far more often than starting something from scratch. Starting with a blank canvas offers many more possibilities (and also pitfalls) than when you have been tasked with a simple feature or bug fix on an existing codebase.
Code Katas give you the freedom to experience setting up a new project, configuring any necessary tooling, and putting in place any test and build infrastructure. For example, it’s a great excuse to try out that shiny new framework or library you’ve heard about but haven’t had the chance to try out yet.
Getting the Fundamentals Right
A competent developer should always be thinking about the runtime efficiency of the code they write. Donald Knuth did state that premature optimization is the root of all evil, but one mustn’t use that as an excuse to deliberately ignore fundamental optimizations. Hardware has gotten faster and cheaper over the years and, at least in the past, one could always throw more hardware at the problem to compensate for sub-optimal algorithms. However, with the increasingly larger datasets that modern computations are carried out on and the expectation of near real-time results from users of these systems, it is vital not to forget the principles of how data structures and fundamental algorithms work.
For instance, it’s well and good to watch a video on a sorting algorithm. But there are real insights to be gained from actually implementing the algorithm — insights such as average and worst case runtime complexity, additional memory requirements, and the nature of the inputs that best suit that particular sorting algorithm.
Learning new Languages and Techniques
In the ever-evolving landscape of languages, frameworks, and tools, it’s easy to stick to what is known. In fact, it is not often that one changes the framework or tools used in a professional project already underway, unless there is a very compelling reason to do so.
There are no such constraints when it comes to personal projects or Katas, so they offer the perfect opportunity to try something new. If something doesn’t work out as intended, apart from the time spent researching and using the technology, there is nothing lost.
Learning a new language, especially one that is significantly different from what one is used to, can make you a better programmer. Someone who is proficient in an imperative or object oriented language can gain valuable and transferable insights and skills by trying to solve a simple Kata in a functional language.
Expanding your Horizons
As developers, we typically end up specialising in a narrow skill set, usually based on the nature of the projects that we encounter over our career. Over time, this has the effect of eroding knowledge gained at university and previous roles.
Say you are a web specialist who spends most of your day building applications that are consumed through the browser or through an API. In this instance, a Kata involving image processing or ray tracing or creating a clone of a classic game like minesweeper or snake might get you thinking of concepts that are completely outside your comfort zone.
My experience with doing Code Katas is that they are educational and fun. They remind me of the reasons why I got started with coding — being able to explore concepts and being creative through code, without any of the constraints or deadlines of a professional project. There are plenty of sites that have suggestions for small Code Katas. Some of my favorites include Project Euler and Coding Dojo, but a quick Internet search will certainly turn up many alternatives that you may find inspiring. You can even challenge yourself with a problem of your own!
Have you tried Code Katas? How has deliberate practice helped you become a better developer?