r/dailyprogrammer • 1 3 • Jul 28 '14

[Weekly #4] Variable Names

Variable Names:

We use variables a lot in our programs. Over the many years I have seen and been told a wide range of "accepted" use of names for variables. I always found the techniques/methods/reasons interesting and different.

What are some of your standards for naming variables?

Details like are they language specific (do you change between languages) are good to share. Or what causes the names to be as they are.

Last Week's Topic:

[Weekly #3] (http://www.reddit.com/r/dailyprogrammer/comments/2bbvqp/weekly_3_favorite_data_structure/)

25 Upvotes

64 comments sorted by

View all comments

Show parent comment

1

u/rlamacraft Jul 29 '14

Can you not just do a search and replace on "i ", rather than just "i" to replace the instances of i as it's variable name rather than its instances within other words?

3

u/Whadios Jul 29 '14

About the most dangerous thing you can ever do is start doing search and replaces trusting pulled out of your ass rules that you hope will isolate what you want. Do you really trust that nobody had a variable name or function that ended in i in that file?

Now you can say you'll use replace and step through each instance rather than replace all so you're safe but we both know you'll grow confident and laziness will take over and there will come a time when you start using replace all to 'save time'.

2

u/Decency Aug 07 '14

Fails for array[i], function(i), etc.