SSブログ

プログラマーとしての練習 [プログラマー現役続行]

The Clean Coder: A Code of Conduct for Professional Programmers (Robert C. Martin Series)

The Clean Coder: A Code of Conduct for Professional Programmers (Robert C. Martin Series)

  • 作者: Robert C. Martin
  • 出版社/メーカー: Prentice Hall
  • 発売日: 2011/05/23
  • メディア: ペーパーバック

この本の「Practice」という節には、プロフェッショナルなプログラマとしての練習(practice)について次のように述べられています。
Practice

Professionals practice. True professionals work hard to keep their skills sharp and ready. It is not enough to simply do your daily job and call that practice. Doing your daily job is performance, not practice. Practice is when you specifically exercise your skills outside of the performance of your job for the sole purpose of refining and enhancing those skills.

What could it possible mean for a software developer to practice? At first thought the concept seems absurd. But stop and think for a moment. Consider how musicians master their craft. It's not by performing. It's by practicing. And how do they practice? Among other things, they have special exercises that they perform. Scales and etudes and runs. They do these over and over to train their fingers and their mind, and to maintain mastery of their skill.

So what could software developers do to practice? There's a whole chapter in this book dedicated to different practice techniques, so I won't go into much detail here. One technique I use frequently is the repetition of simple exercises such as the Bowing Game or Prime Factors. I call these exercises kata. There are many such kata to choose from.

A kata usually comes in the form of a simple programming problem to solve, such as writing the function that calculates the prime factors of an integer. The point of doing the kata is not to figure out how to solve the problem; you know how to do that already. The point of the kata is to train your fingers and your brain.

I'll do a kata or two every day, often as part of settling in to work. I might do it in Java, or in Ruby, or in Clojure, or in some other language for which I want to maintain my skills. I'll use the kata to sharpen a particula skill, such as keep my fingers used to hitting shortcut keys, or using certain refactorings.

Think of the kata as a 10-minute warm-up exercise in the morning and a 10-minute cool-down in the evening.
解決方法が分かっている問題を、練習として行うことが述べられています。そして、仕事でプログラミングすることは、練習ではなく、パフォーマンスだとも述べられており、プロのプログラマであれば練習をすべきだということです。

これを読んでから、簡単な問題をテストファーストで解く練習をやり始めてみました。最初は、30分とかかかっていたものでも、毎日繰り返していると10分ぐらいで終わったりします。あるいは、本を見ながら何とか書いた短いスクリプトでも、何も見ずにスラスラと書けるように練習したりするようにしています。

短い練習ですが、練習することで、自分のスキルを維持して向上させるのに役立つかと思います。