Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What happens if you don't use `a` until line 23 of the function, far from its original declaration?

Then you have horribly violated the previous poster's note that the more local a variable is, the shorter its name should be.

I find single or 2 letter variable names a horrible curse to the uninitiated of a problem domain. It means you have an extra step figuring out a program, what the abbreviations even mean in that particular domain.

It is a trade-off. If you master that domain, you'll be using that all the time, and you'll get the savings all the time.

You need to amortize the cost of memorizing the notation over the expected usage of that notation. Programmers, by profession, have to use a lot of notations from a lot of fields, and therefore benefit from using notations that require a minimum of memorization. But that is not always the right trade-off.

As I pointed out in https://news.ycombinator.com/item?id=5157539, The rule is not that you need long or short variables. You need meaningful ones. A short variable name is inherently ambiguous, which can lead to confusion and mistakes. Thinking through anything with a long-variable name abuses your working memory, limiting how complex your thoughts can be.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: