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

2

u/[deleted] Aug 05 '14

Why would you search and replace 'i'?

3

u/newpong Aug 21 '14

well, this probably doesn't happen too often, but i actually remember having to do this before. i, j, and k are often used in physics as the unit vectors for the x, y, and z axes, respectively. I was working on some sort of computational model that was initially one-dimensional, so i and x were the units I chose, but I didn't really plan ahead or have any expectations of where I might go with it, so when it was extended to 2 then 3 dimensions, the labels didn't make sense with what was conventionally taught, so I swapped the i's and the k's to re-orient the system