Code Katas

“Practice doesn’t make perfect, practice makes permanent.”

A kata is a set of practice moves used in the martial arts to practice techniques in a controlled environment. In martial arts katas are often practiced at slow speeds until the technique is perfected. Katas are useful in a strategic sense, in that they help you improve your structure, so that you are not as easily knocked off balance.

Drills are different than katas. Drills are intended to enable someone to react to a changing environment. They are useful in a tactical sense, in that they help you be capable of dealing with the dynamics of a fight, so that you can react appropriately to having been knocked off balance.

Episode Breakdown

09:38 What is a Code Kata

“Create for yourself an environment where it is comfortable and safe for you to make mistakes.”

Code katas help you to build solid practices in a controlled environment. The idea here is to create a situation with a known problem space and use it to safely practice the same thing over and over again until the technique is fluid, solid, and relaxed. They can also be quite helpful first thing in the morning to help you establish momentum.

11:30 The Importance of Code Katas

A regular schedule of practice for a known problem in your environment makes you more capable of using your environment effectively. This practice in using your environment will help you optimize your flow and figure out ways around problems you regularly face, without having to worry about specific implementation details, since you are effectively controlling for those.

You can also use them to practice tightening up code using a known problem space, using different language constructs to do so. This will help keep you from getting into a rut with your practice. Code katas are an excellent opportunity to practice things like Test Driven Development (TDD), refactoring, and unit testing.

16:08 Suitable Problems to Solve

Short, reasonably simple problems that you can deal with as a unit are the best choices for code katas. You generally want to avoid complicated issues such as user interfaces, multithreading, and talking to databases, unless you are trying to train specific skills around those.

You want a problem that takes around 30 minutes to solve. One that can be made more (or less) difficult, or can be varied in some manner, particularly if you are practicing things like unit testing.

24:05 Unsuitable Problems to Solve

Problems whose simplest form takes you over an hour to complete are probably not a good place to start. Conversely problems that take less than 5 minutes to solve in their hardest form are also not worth doing. They don’t give enough variance for growth. However, they can be good little puzzles to help establish momentum, however.

You also don’t want a problem whose solution is wildly different than the sort of problems you hope to solve. You want focused practice for things you are likely to encounter, or hope to encounter.

31:00 Practice Makes Permanent

“If you’re doing something in a bad way over and over again, you’re going to be doing it in a bad way for a very long time.”

Go slow until you get it right, then work on speed. It does no good to solve a problem incorrectly, but quickly. Do your coding kata first thing in the morning, while you are fresh, at least three times a week.

Once you’ve mastered the problem and feel that you can’t improve or optimize it any more, find a different one, vary the current one, or add a practice (like unit testing). Come back to old problems periodically and try them again. You’ll likely find that your approach has improved.

Always be on the lookout for ways to avoid using the mouse. Being able to use shortcuts to do things instead of digging through menus will help you greatly.

Try to practice in the same environment as you do your work, or as close as possible. This will help you learn.

IoTease: Project

BuddyBot

This is a robot programmed entirely in Swift. It comes from a blog created by a Swift programmer and his daughter after building the BuddyBot as a summer project. This is a fun project for families with kids in elementary school and up.

Hardware

  • Rover 5 Chassis and Motor Controller
  • BeagleBone Black
  • Battery Pack and Holder (6AA)
  • Tilt Sensor
  • IR Obstacle Range Finder
  • MaxSonar Range Finder
  • Mini Boards and LEDs
  • Button
  • Jump Wires and Resistors
  • Finders

Software

  • SwiftyBones
  • BeagleBone Black

Tricks of the Trade

Usually when when you have a problem there are actually two problems. The problem you are solving but also how you are thinking about the problem. A lot of the way you are thinking about a problem makes the problem more or less difficult.

Editor’s Notes:

Tagged with: , , , , , , , , , , , ,
One comment on “Code Katas
  1. DA says:

    Been listening for a little while now….some really good stuff, wish more developers listened to you. Where do you get your code kata material?

Leave a Reply