Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 175
  • 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?

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.


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.
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.
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!
Mr_FulanoAuthor Commented:
Correction, Sethi was awarded 100 not 150... sorry for the miscalculation.

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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