People: ghost_75_24@…
Variable names–can they be too short or too long?
Everyone who’s taken any type of programming class has had the obligatory lesson of creating variables. Going from chosing the type for a specific function all the down to the name being very descriptive of what the actual variable does. How many of us actually keep those lessons today, years after the class has been over, much less even being awake in class that day? It’s almost two years since I’ve been programming professionally and those lesson come back to me almost everyday. But one thing I’m having second thoughts about is the way I name a variable. Specifically, I think I make the variable name too long.
The reason I believe my variable names are too long because for one, they are! Depending on what the variable holds, I make it long. It’s usually the format of what the variable holds and where the variable is located. For example, If I were to have a variable in a Java applet that holds a SSN in an employee info form. the variable name might be “ssnEmployeeInfoForm” with EmployeeInfoForm” being a part of the actual whole name of the form. This can get very tedious over time. I’ve read over many texts and blogs and group posts, etc of “following established naming conventions” of a particular company, etc. This puts me at a great debate. I say this because of the current project I’ve been working on for the almost two years. I’m working in a division that had no IT person at all before me, muchless a programmer for me to be mentored by. Also, there is no one in the college (where I work) that has ever designed an in-house program/application for use. And the main part is there is no established naming convention. So, I’m basically using all of the academic knowing I have and applying it the best way I can.
My problem is considering my situation, are my variable names long enough or too long? Should variable names be as descriptive as they can be or just brief enough to be ok? I also remember the lessons about in the good ol old days of computing when variable names had to be very short because of writing a program with less than 1 Meg of memory and only KBs of hard drive space. Totally different from today’s world. So, I want to put this out there to you TechRepublic. I’d like to hear your opinions.