Friday, July 20, 2007

Code Katas and Programming Exercises

We all know that the way to become a better developer is to both study and practice our craft.

The reading happens from books, blogs, news sites, and tutorials.

The practice? Sure, there is the day to day coding. Sometimes, we really need something with a scope beyond the day to day. You already know that really well anyway.

I have always steered junior programmers to TopCoder. The idea is that the speed of competition can stimulate faster learning. Even if they don't compete, the practice areas are just plain good practice.

Project Euler also offers up a big set of small programming challenges. Just the thing to play with on the lunch break.

Another good site is Dave Thomas' CodeKata blog. I really like the idea presented by Dave. Take a problem per week. Create a different solution (read implementation) each day of the week. Let's face it, we all know that most problems can have many different solutions. Why not explore the possibilities?

Here at the office, I've started a (completely voluntary) group version of the code katas. On Monday, I send out the problem (to a mailing list). Everybody works, mostly independently, on a solution per day. On Friday, we all get together over lunch and review each other's solutions over chips and salsa.

I have observed many benefits to this technique. Everybody learns by seeing other people's solutions. Many of the junior developers go around asking questions as they work on their solutions. Since it is only an exercise, most everyone has lost the fear of the code review. Everyone is claiming to have fun. Communication between development teams is up. Code quality all around is improving. Participation is increasing (though that may be due to the salsa).

Since we are a java shop, I send the problems out with a set of jUnit tests. One test per day. I am also encouraging TDD by getting everyone to write test cases instead of using System.out.println

The change is slow at first. The question is "why not just print it out?"

My answer, "What do you do after you get everything working?"

everybody's answer, "delete the print lines", and they start to realize that my question was a set-up.

This brings in the key point (the Socratic Method rocks). Those prints contained information, knowledge about how a piece of code is supposed to behave. When it is deleted, the knowledge is lost. There are also the all the standard arguments, like confidence in refactoring. For many, it takes some effort to change to a different method of thinking but, it appears to be gradually happening.

As the use of these exercises continues, I hope to introduce other systems for testing and development like, EasyMock, Fit, and jBehave.

So far, it looks like daily programming exercises are a good technique for code improvement and enhancing team cohesion. I'll post updates to report progress.

Update:
I've just been informed of another programming contest site, like TopCoder, called Sphere Online Judge. Thanks llimllib.

Update:
I've just read a post, Kata and Practice that shows one person's experience. An interesting read and it mentions another resource, The Coding Dojo.

Labels: , , ,

permalink
Links to this post
1 comments

Upgrading to Eclipse Europa

I've recently taken th plunge and upgraded my Eclipse environment from Callisto (3.2) to Europa (3.3).

One of the first things I noticed is a significant improvement in performance. My machine isn't a lightweight by any stretch but, Eclipse 3.2 definitely used some resources. Now that I am using the newer version, things flow much faster. (One of my co-workers posted about using Europa on an older computer ; he seemed to thing it worked pretty well)

Being a major proponent of keyboard shortcuts, I have to say, some of the changes interrupted my programming flow. For example, I usually follow the method of test driven development. So, I often used the short-cut "ctrl-F11" to run the last thing (usually, my jUnit test). With Europa, I found that it launched a contextual dialog based on the current file.
Ouch!
Fortunately, the preferences allowed me to switch it back to the previous behavior.
window->preferences
run/debug->Launching

Cool, if things change, at least it is pretty intuitive to get back to the normal way of working. Finding the preference literally took about 30 seconds.

Most of the other shortcuts still work as expected.

There are some nice new refactoring options too.
Really cool is, "Introduce Parameter Object". Select a method, hit alt+shift+t for the refactoring menu. Then "P" to select that option.
This allows you to replace a bunch of parameters with a single object. It also changes all of the calls to method to use the new object. Great for refactoring old code.

The next is "Introduce Indirection". This one is really great when you are refactoring code that uses an external API. Especially when you need to implement an interface that you can't change. I found a great article, "Unleashing the Power of Refactoring", that covers this one with great detail.

In the web tools (WTP), there is a new page editor. It is a split pane editor with the page on the top and the source on the bottom. They scroll together, and changes are shown "live".
Schweet!!!
The horizontal split is a little weird at first. I like a whole page of code. But, you can now have multiple editors open for the same file. To quote Rachel Ray, "How cool is that?"

Even better, most of the editors have built in spell check with ctrl+1 auto-correction. Javadocs, html, properties files,.....
BooYah baby!!!

It is rare that a minor release (3.2 to 3.3) of any software has such great improvements. But, for adding new features that can stay out of the way, for improving performance, and stability, I give Europa two thumbs up.

Can anybody ever remember an update to any IDE that performs better on the same hardware?


Update:
I forgot to mention, the contextual auto-complete. This gets better in every release. It's funny that I can't point out anything specific but, just notice how I find I keep getting closer to the point of "thought->code".
An interesting post mentions a little more about it.
Aren't the best changes, the ones that help you work better without realizing that anything has changed?

I can't wait for a revival of the emacs/vi war over minimum keystrokes happening with Eclipse/NetBeans.

buaahahahaha!!!

Labels: , ,

permalink
Links to this post
9 comments