liveBook · Manning

Code kata

As explained in The Creative Programmer

A code kata is a small programming exercise repeatedly implemented or rewritten to practice software development skills.

A code kata is a small programming exercise rewritten repeatedly to build muscle memory and practice the craft. Borrowing the idea of a martial-arts choreography, it makes repetition a way to notice choices rather than merely reach a finished program. section 8.4.2

The point is not to preserve the first solution. Try a small problem, explore a design, then discard the result and begin again. Rewriting can expose alternatives that were invisible when the goal was simply to make the code work. section 8.4.2

A useful kata habit can be deliberately small:

  • Choose an isolated exercise or a narrowly bounded feature. section 8.4.2
  • Implement it with a test-first approach when that suits the exercise. section 8.4.2
  • Revert or throw away the attempt, then try a different starting point or design. section 8.4.2
  • Compare the options explored instead of treating the retained version as the only lesson. section 8.4.2

The bowling-game kata

After learning bowling’s scoring rules, implement a scoring program test first. A first attempt might begin with a Game class, Player, or ScoreCalculator, and might consider inheritance for spares and strikes. If the design becomes messy, reset it. The restart is part of the exercise: it tests whether a different decomposition makes the rules easier to express. section 8.4.2

Katas are often detached from day-to-day work and may train syntax or algorithms on online platforms. They can also become a fast ideation tool for production work: isolate a piece of the current project, practice it with colleagues, and see whether its real constraints produce more relevant learning than a traditional puzzle. section 8.4.2 section 8.5

How The Creative Programmer covers it

How deep it goes
Defines the practice and gives a bowling exercise with design questions, while leaving implementation details open.
Examples
Uses a bowling scoring program, discarded feature attempts, isolated exercises, and pieces of a current project repository.
What it assumes
Assumes enough technical knowledge to move beyond syntax and mechanical test errors, while keeping exercises small.
What you can do after
Practice/perform repeated rewrites to explore and compare possible implementations before committing to a solution.
How it connects
Connects code katas with test-first development, unit tests, inheritance, algorithms, syntax, and programming-language learning.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Creative Programmer. The section links point to the parts of the book it draws on.