I was just looking at some source code for a MUD that I wrote a while ago, and I noticed that many of the names for variables make no sense. There are variables with names such as "qw", "we", "d", and "ty". And they aren't just loop variables either, they're important members of a class. I must have named them how I did because their uses are so hard to explain that I would have had to give them very long names if I wanted the names to make sense. I don't know how many other people name variables like this on projects they aren't planning for anyone else to ever see, but I wouldn't recommend it. There's always going to be someone who wants to see your source code, and will laugh at it.

In six months, you forget everything about that program, and when you re-read the code, you'll have just as bad a time trying to understand it as anyone else would. At least that's what my programming II professor told us, and when I look back at projects I wrote for that class, I have no idea what most of the variables do.

Hmmm, I wonder how many variable names in Windows 98 are one or two letters.

If you do not want to give variables long names, use a comment to explain what they are doing.

It does not matter that you do not expect someone else to read the code. For all practical purposes, when you read your own code you have not looked at for some time, you are "someone else." Except, you will not be laughing, you will be tearing your hair out.

Log in or register to write something here or to contact authors.