767 posts
  • Author had a Free File of the Month
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Sold between 1 000 and 5 000 dollars
outandouter says

Is it a bad habit to give variables, longer names like this:

var mainMenuButtonsActiveWhenFocused:Boolean;

Also, is it bad to keep a large number of variables where you could manage to keep less?

- Kamil Waheed

807 posts We're a nice team!
  • Elite Author
  • Author had a File in an Envato Bundle
  • Has been a member for 4-5 years
  • Interviewed on the Envato Notes blog
  • Exclusive Author
  • Sold between 100 000 and 250 000 dollars
  • Contributed a Tutorial to a Tuts+ Site
+4 more
ThemeFocus says

I think large number of variables not bad. :)

767 posts
  • Author had a Free File of the Month
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Sold between 1 000 and 5 000 dollars
outandouter says

What about longer names? Is that bad?

2671 posts
  • Bought between 50 and 99 items
  • Elite Author
  • Exclusive Author
  • Has been a member for 7-8 years
  • Referred between 100 and 199 users
  • Sold between 100 000 and 250 000 dollars
  • United Kingdom
  • Won a Competition
Chuckanucka says
What about longer names? Is that bad?

You should keep them succinct, but its not that big of a deal. Its probably more important for you to remember what they mean.

1550 posts
  • Bought between 1 and 9 items
  • Europe
  • Exclusive Author
  • Has been a member for 6-7 years
  • Referred between 100 and 199 users
  • Sold between 50 000 and 100 000 dollars
dSKY says

No, there is no performance impact (your applications won’t run slower) if you use longer variable names.

1621 posts Building the Web.
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Exclusive Author
  • Author had a File in an Envato Bundle
  • Most Wanted Bounty Winner
  • Bought between 50 and 99 items
  • Has been a member for 4-5 years
+2 more
ZoomIt says

Less variables is a plus memory-wise :)

767 posts
  • Author had a Free File of the Month
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Sold between 1 000 and 5 000 dollars
outandouter says
Less variables is a plus memory-wise :)

This is what I was expecting… :)

... and I was expecting the same with the longer names which doesn’t seem to be the case!

Thanks!

3072 posts
  • Has been a member for 6-7 years
  • Won a Competition
  • Sold between 50 000 and 100 000 dollars
  • Bought between 10 and 49 items
  • Referred between 50 and 99 users
  • Exclusive Author
  • Romania
wickedpixel says

:nerdy:
The long names can also be a sign that the thing can be a little better structured.
For example that variable does not need to be bigger than “itemsActiveOnFocus” if the setting is already present in the option area for the main menu.

767 posts
  • Author had a Free File of the Month
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Sold between 1 000 and 5 000 dollars
outandouter says
:nerdy:
The long names can also be a sign that the thing can be a little better structured.
For example that variable does not need to be bigger than “itemsActiveOnFocus” if the setting is already present in the option area for the main menu.

Totally agree with you!

5856 posts
  • Exclusive Author
  • Author had a File in an Envato Bundle
  • Elite Author
  • Has been a member for 6-7 years
  • Sold between 100 000 and 250 000 dollars
  • Repeatedly helped protect Envato Market against copyright violations
  • India
+3 more
VF says

I don’t think number of variables being much sensitive on memory usage. In case if it is unavoidable to use large number of variables for temporary use, you can free up memory by deleting them after usage.

delete myVar;
by
by
by
by
by
by