• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 178
  • Last Modified:

Length of Variable Names and Performance Impacts

Hi, I've wondered this for quite some time, but never really got around to asking...

When we choose a variable's name, is there any type of performance impact depending on the length of that string?  For instance, would the variable "i" perform any better in memory than say, something like "str_My_Variable_Name_Which_I_Really_Like_And_Want_To_Use."  Clearly this is a gross exaggerations, but it's meant to illustrate my point.

Is there a rule of thumb for the length that a variable name should be kept?

Thanks,
Fulano
0
Mr_Fulano
Asked:
Mr_Fulano
3 Solutions
 
zorvek (Kevin Jones)ConsultantCommented:
No performance impact at all. All it might do is slow the compiler down a wee little bit. The key to good names is readability.

Kevin
0
 
Raynard7Commented:
Hi,

the reason why it should not slow anything down as when .net compiles into its intermediate language - it does not necessarily use the names that you actually put in to reference the data locations,

becuase of this there may be a hit in the compiler - which is what kevin was referring to above - because there is more data to parse, but the end result should be the same.
0
 
SethiCommented:
No need to think about this impact at all. It is so little an impact that if you start thinking so deep you can not do programming. Have variables which are defined with conventions and are immediately understood. So even if you have to use big names use them - as maintaining the project becomes very easy with good variable names.
0
 
Mr_FulanoAuthor Commented:
Thanks for the information and for putting that to rest for me.

Having said that, I increased the points  to 500 (Max) and awarded them in the following manner since you all helped.

Zerveck - 150 ... he was first to answer
Raynard7 - 250 .. he provided the best answer, because he gave a reason
Sethi - 150 ... he provided good info as well

Thanks to all!
Fulano
0
 
Mr_FulanoAuthor Commented:
Correction, Sethi was awarded 100 not 150... sorry for the miscalculation.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now