Live data from Hacker News

A Guide to Naming Variables

a-nickels-worth.blogspot.com

1–10 of 175 posts

Re: A Guide to Naming Variables

#2
Good advice. If this sort of thing is appealing to you, then read Code Complete by Steve McConnell. It's basically an entire book full of very solid advice of this sort.

Re: A Guide to Naming Variables

#3
when it's coding as fast as humanly possible, the last thing I want to do is slow down to think of good var names. I'll often just name something "foo" if I can't think of a good name and come back and rename it later. Sometimes it's a little better than foo but still not perfect but I'll leave that and move on to something else. I really don't like the idea that code must be perfect. Code is never perfect.

Re: A Guide to Naming Variables

#4
Most of this, even if it's not my preference, I would never bother arguing with. But I have a question about a practice that is tremendously widespread.

I have real trouble with single-letter variable names like "c", for any function more than, say, 2-3 lines. I scan the code and it increases my mental load because I have to remind myself what it means.

Obviously a lot of people don't have problems with this, but I do. Anybody else?

Maybe it's because I jump around a lot from function to function?

Re: A Guide to Naming Variables

#7

when it's coding as fast as humanly possible, the last thing I want to do is slow down to think of good var names. I'll often just name something "foo" if I can't think of a good name and come back and rename it later. Sometimes it's a little better than foo but still not perfect but I'll leave that and move on to something else. I really don't like the idea that code must be perfect. Code is never perfect.

But what happens if you die and someone else has to pick up where you left off?

Re: A Guide to Naming Variables

#8
Off-topic, but blogspot links are a constant frustration for me on the phone. It's super easy for my fingers to swipe slightly left/right when scrolling and triggering blogspot's next/previous post navigation. I can even accidentally end up slightly scrolled horizontally and have no way to see the left side again.

As a result I mostly ignore blogspot links. But this seems up my alley (http://akkartik.name/post/readable-bad). Anybody else run into these issues? Anybody have suggestions or workarounds? Why do technically savvy folks not notice how crappy blogspot has gotten?

Edit: PSA for blogspot owners https://productforums.google.com/forum/m/#!topic/blogger/8hN...

http://chrisltd.com/blog/2012/03/blogger-mobile-theme

Re: A Guide to Naming Variables

#9

when it's coding as fast as humanly possible, the last thing I want to do is slow down to think of good var names. I'll often just name something "foo" if I can't think of a good name and come back and rename it later. Sometimes it's a little better than foo but still not perfect but I'll leave that and move on to something else. I really don't like the idea that code must be perfect. Code is never perfect.

But what happens if you die and someone else has to pick up where you left off?

someone else is going to cry because the coder is dead and the code is unreadable

Re: A Guide to Naming Variables

#10

when it's coding as fast as humanly possible, the last thing I want to do is slow down to think of good var names. I'll often just name something "foo" if I can't think of a good name and come back and rename it later. Sometimes it's a little better than foo but still not perfect but I'll leave that and move on to something else. I really don't like the idea that code must be perfect. Code is never perfect.

But what happens if you die and someone else has to pick up where you left off?

The world will stop turning and it will all have to be rewritten from scratch.
Post reply on HN