Coding Kata: Practice Time for Programmers

4 Sep

Before I came to Fortigent, I spent two decades as a musician and educator.  Training for a career in music often starts

Arban

in elementary school.  I joined the school band, learned to read music and played an instrument.  I continued on through middle and high school.  I learned to practice, to perform in front of an audience, and to listen to music.  I continued through college, learning music history, music theory, and to teach music.  I started reading music educator’s magazines and blogs.  In my senior year, I spent months student teaching in a classroom with a master teacher, practicing everything I’d learned.  By the time I got to my own classroom, I didn’t feel completely prepared, but I’d had real, hands-on experience in a professional setting.

commodore64

So how did I get from teaching music to being a software engineer at Fortigent?  I started programming text-based adventures in BASIC on my Commodore 64 as soon as I was tall enough to reach the programming manuals on my father’s bookshelf.  For years, I programmed little games or small applications, but didn’t actually decide to get a formal technical education until I was on maternity leave from teaching and had some time.

Going from music to programming was a bit of a shock.  I took classes, talked to my professors, did programming projects, and read blogs about software engineering.  This college experience was really different from the first, however.  ProjectThe two things that I really missed in the computer science degree were practice and that final student teaching-like internship.  I found myself a part-time, volunteer position with a videogame company as I entered my final stretch of college classes.  I learned a lot about teamwork, source control, and how to work and navigate in a large business application.  The other programmers were helpful, but I was still lacking the one-on-one experience that I’d gotten as a student teacher.  I also had not learned to practice.  At the time, I thought of the programming projects as practice, but those projects were nothing like the practice I had done as a musician.  There was no repetitive improvement or long term reflection on a set of exercises.

Soon after I got to Fortigent, someone gave me Bob Martin’s (usually known as Uncle Bob) book The Clean Coder.  As I read through the book, the chapter on practicing really hit home.  Uncle Bob wrote about how many software engineers never really learn to practice.  How can someone be a good programmer if they don’t know how to practice and don’t have a master teacher working closely with them?  “Perhaps the best way to acquire ‘Design Sense’ is to find someone who has it, put your fingers on top of theirs, put your eyeballs right behind theirs, and follow along as they design something.”  (http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata)  While I’ve been doing a little bit of this at work (the programmers here at Fortigent don’t seem at all shy about me standing over their shoulder asking questions while they program), this is not the same as programming what they are programming.

About a decade ago, programmers started talking about practicing.  Dave Thomas mentions sitting at his son’s karate lesson watching the children perform kata.  The students followed the movements of a master teacher and would perform these same movements at home as practice.  As Dave Thomas was watching the students learn their kata, he had been experimenting with a small coding exercise, doing it several different ways, trying to make it more efficient.  It hit him that a small exercise such as what he was doing was very similar to the practice movements the students were performing. (http://www.codekata.com) Just as in Japanese martial arts kata, the purpose of a coding kata is to practice.  A coding kata is a small set of exercises that encourage trying out different combinations of coding techniques in a practice environment.

To me this feels like when I would go through a piece of music with my college trumpet teacher – he would play a line of music and I would play it back to him trying to get the same sound, inflections, and tone as he did.  As a software engineer, I have been going through the kata of the software engineering community, trying to get a feel for good programming.  Sometimes I will try an exercise on my own several times, seeing if I can improve upon my code each time.  Other times I will find a video of someone else doing the kata, so I can learn from how they program.

powerpointAt The Rockville .NET Group (RockNug) meeting on September 11, 2013, I will be sharing part of one kata I’ve found particularly useful, Roy Osherove’s String Calculator Kata.  I found it to be a great introduction to Test Driven Development.  I’ve watched several people’s online videos of the kata being done in several languages, using several unit testing frameworks.  I felt that his kata imparted to me the idea of working incrementally and solving problems as simply as possible.  As I worked through this kata, I read comments left by other readers, which really gave a sense of getting to hear what people were thinking while doing the kata.

stringCalculator

I’ve been developing a sense of how to write tests before code, I’ve been learning to work incrementally, I’ve been learning to refactor my code, and I’ve been striving to think of simpler solutions to problems I encounter.  I’ve also been learning technology basics such as how to use a testing framework, keyboard shortcuts, and all the wonders of Resharper.  I have found several good resources and kata about refactoring legacy code, and this is where I plan to focus next.  I believe this will provide a good starting point for testing and refactoring legacy code that I will be working with shortly.

One Response to “Coding Kata: Practice Time for Programmers”

  1. Jamie McIntyre (@Jamie_McI) September 8, 2013 at 9:51 am #

    Brilliant post – wish I was here for RockNug.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: