On variable naming conventions

Naming variables (that includes functions) is one of the most flamed subjects in the computer programming world. Some people say you should use underscore (_) to separate words in the multiword names, like this_is_my_variable. Others believe that separation should be done by capitalizatioon like thisIsMyVariable. Agreeing on what should come first – a verb or a noun (display_form vs form_display)- is yet another question.

This reminds me of an old joke. There is an exam in C programming class at college and one of the students finishes first just a few minutes after the test started. So the professor comes up to him checks his code and says: “Very good, young man. You can use the remaining time to fix names of your variables. Make them all self descriptive.” Student nods in agreement and starts to work. Few moments later he is finished again and shows the result to the professor. And what does the professor see? All the ‘i’s, ‘j’s, and other one letter variables were converted to selfdescriptivevariable1, selfdescriptivevariable2, selfdescriptivevariable3, etc.

Why did I start this post today? Oh, well. Something got me started.

Leave a Comment