||[Mar. 31st, 2008|07:10 pm]
Am I the only programmer who is occasionally totally stumped because I can't decide what to name a variable? I mean, to the point that I have to take a break.
Variable naming is especially important to me because I use comments sparingly and believe it's better to let code document itself where possible. But surely, I can't be the only one?
I think it's pretty common.
I don't take breaks, but it *will* nag me from some corner of my brain, so I'll go back and rename if a better name strikes me in the next few minutes.
I knew a guy in high school who named every variable after his cats. He had a lot of cats.
lol, i hope he grew up to become something other than a computer programmer :)
There was a short period of time where all of my variable names, function names, and comments were in Esperanto.
Now, I'm definitely of the camp that a two- to three-letter variable name is fine for something that only has scope for three to five lines. So, I don't usually end up sweating variable names much. On the other hand, I often change major function names each four or five times in the first two days on a piece of code.
hey, if you're going to be in austin we could get coffee. i like randomly meeting mathematicians :)
super! i'll be there sometime around the 27-30 of may :)
name it something and be willing to change the name later if you think of a more accurate name.
yeah has happened a LOT to me
and unlike what others here have suggested, i don't think a temporary name works. at least not for me. i usually don't like to revisit my own code.
but yeah - i don't break my head too much about it - just put some very arbit name and thus "postpone" the problem - of figuring out why i gave what name i gave.
What? All variables can't be named i,j,x, or a?
Clearly, I must be a math student :-P
i used to do that in HS. when i ran out of names i started using 'aa' and so on. gets just a little hard when you have 20k lines of code :)
Yeah, I do this quite a bit as well, especially with temporary variables - e.g. inside loops and stuff. I often end up calling a temporary object 'obj' or something, but it never quite sits right heh.
Delete Track This
What? You have forgotten all the software engineering they have taught us? A variable name of average length would be :
ThisVariableIsPerhapsATemporaryPointerToFillUpTheFunctionPointModelEstimate, and with that kind of length you can never run out of variable names.
What a disservice to good work done by the people of firstname.lastname@example.org. What a waste of the eight-hours-per-lecture of painful slide-preparation our Professor subjected himself to.