Wednesday, January 28, 2009

Code Kata

One of my goals for quite a while has been starting a Code Kata practice. Dave Thomas nicely sums up the benefits of such a habit at the above link. However, there are several other reasons I want to start this practice, all of which fall under the category of becoming a better programmer, but which have materialized after starting my job as a consultant. The main factor in recognizing these areas in which I'd like to improve, has been working within very aggressive budgets (time-wise) that don't allow much time to stray from the well-beaten path.

Good Programmers Write Good Code; Great Programmers Steal Great Code
One consequence of aggressive budgets is that it usually makes sense to find existing code that does what you need it to do, rather than writing it from scratch. Between sample code in documentation, generic code from previous projects and personal blog posts, it's almost impossible not to be able to find existing code that at least points you in the direction you need to go.

Unfortunately, I think this has somewhat diminished my ability to quickly solve problems on my own. I want to use the Code Kata practice to plop myself in front of a blank editor and pull the code out of my head.

Unit Testing
Ever since taking a TDD course taught by Robert Martin, I've wanted the same experience I had in his class in my daily programming activities. Having a suite of tests to run after each code change and seeing those tests pass was very gratifying. Even more gratifying was changing the code, seeing an error, and knowing exactly where and why that error occurred because of the tests we had in place.

Most of my projects so far as a consultant haven't been very business-rule intensive. So the model objects in the code were pretty simple and the projects wouldn't have benefited that much from a unit-test suite.

The problem is, even if unit tests would have been useful, I don't have enough experience with the standard testing tools to quickly integrate them into a project without wasting valuable budget time.

I want to use the Code Kata practice to learn the different testing tools that exist, including tools that test at a higher level than a unit. I'm also hoping to get better at understanding what to test and how to write better tests.

Learning new tools/libraries/languages/specialty areas
This last point is similar to the previous one, but I also want to expand my tool set in other areas. One example is becoming an expert in a standard editor that I would use across languages in order to increase my efficiency in editor use. Another example, is focusing the Code Kata practice on an area such as Artificial Intelligence or Image Processing for a set amount of time.

Next Steps
The biggest problem in getting into this habit, like any habit really, is finding the time to do it. I know I will not be able to follow a set schedule so I will just have to be disciplined enough to dedicate some time to it every few weeks. Hopefully, posting on this blog will give me a way to stay accountable.

My first practice will be to review The C Programming Language. I already know C, but I think it will be a good way to review and give myself the pleasure of making some fast progress when I start. It certainly won't hurt to reinforce some of the basics again. And it will also give me some easy programs for unit testing, allowing some quick progress on that front.

The other thing I'd like to do during this first practice, is to learn Emacs and eventually use it as my standard editor. This will likely take quite a bit of time, but I need to start sometime. But again, it will help to start out small, reviewing a language I already know instead of taking on too many new areas at once.

No comments: