Wednesday, July 18, 2007

Revisiting comments

Back in May I wrote a response to a Slashdot article about writing comments. The jist of my response was that most times you can get away with not writing them if you write self-documenting code.

And the important part of this is the "self-documenting" part. C# lends itself very well to being written in an easy to read fashion. I can't say the same about C++.

Like most computing graduates I have had exposure to C++, but all my commercial (i.e. real world) experience has been in C#. Today I had to look at C++ code, and I didn't enjoy one bit of it.

Esendex's PC SMS download is a C++ Windows application that sits in the system tray, notifies you of new inbound messages and allows you to send SMS in much the same way as you would an email. It's been around for a while now, but I can't say I've worked on any part of it.

We had a customer today who reported that the application was having trouble with the initial connection. Having no experience in commercial grade C++ applications I found it very difficult to track down even how to switch logging on. A few comments here and there would have eased this greatly.

But I still don't believe source code should be swamped with comments. When you're working with a fluid code base (as you do with XP), code is continuously moved around as the design changes, and no one wants to maintain comments as well as code.

No comments: