Friday, July 23, 2010

What's in a name? (Or Notes to Self Regarding Coding)

A couple of months ago (read: end of spring semester), I started writing so code (in java if anyone cares). It all started when I wanted to test some I was considering for my research. Attempting to be smart, I decided I would just write the program for reuse later. Now, that was not my mistake. The mistake was what came next: thinking I would brilliantly name all of my classes really good long descriptive names. My logic being that months later I would easily be able to use the code for the final intended purpose!

I have learned a new lesson: really long names are often just as problematic and did I mention a pain to type? However, I had no problem trying to figure out what was what. I think that was mostly due to the massive comments I left myself too. I have heard the wisdom that descriptive names make the code more "self documenting".

So the question really is: is there a balance between being descriptive and just being silly? Is it better to have names that are only 5-15 characters long? Or is 25+ characters just right or too long? Is it only really long when it gets over 45 characters? (OK I feel like the Goldilocks of programming at the moment...) Does the long names actually make the code less clear?

No comments: