Pwd stands for: ________? Correct, you guessed it! Once an abbreviation or acronym becomes widely used it makes sense to use it as a variable name for as long as you live.
This comment really deeply gets to the heart of the issue. Programmer X thinks "I'll abbreviate because MAN IT IS SO OBVIOUS what the abbreviation is, what sort of idiot would think anything else?". You have nothing to lose by typing: let password = '' as opposed to let pwd = ''
Why I'll never abbreviate a variable as long as I live
91–100 of 111 posts
Re: Why I'll never abbreviate a variable as long as I live
#92Earlier quoted context omitted.
In math, notations are designed to make statements about the problem domain concise. Once you pass a certain degree of concision, longer names impede readability rather than enhancing it. That is because the ability to take in an entire complex expression or subexpression at a glance tells you things—and lets you see patterns—that wouldn't be as apparent if longer names were used. Programmers in the APL tradition und…
If you read it and translate what he's saying to programming, you can glimpse a form of software that would make what people today call "readable code" seem as primitive as mathematics before the advent of decimal numbers seems to us. This is an extraordinary (and enticing and often advocated) claim that has, so far, failed to produce the extraordinary evidence. It says something that a person as concerned with notat…
Imperativeness is a separate matter. One can easily have it without longDescriptiveNames, and although I don't have Knuth handy, I imagine he did.
Re: Why I'll never abbreviate a variable as long as I live
#93Earlier quoted context omitted.
"I ran the code through minify, but it's bigger now?!?"
I don't understand. Why would one submit a minified code for a review? A friend of mine used to work at a place where one of the coder actually used 'a', 'aa', 'aaa'...when naming variables.
Re: Why I'll never abbreviate a variable as long as I live
#94I was recently implementing a geometry algorithm which I looked up on quora. It was described using typical vector notation, using r,s . t,u. Since I referenced the algorithm in the comments, I decided to use these same variable names in my code. I think this is the right choice, but my code reviewer didn't. But he didn't click on the quora link. Why is okay for mathemeticians to abbreviate things but programmers? Is…
link to the post you got it from here
Vec_r, Vec_st, Vec_u
If you just used the raw letters that's jank. Single letter variables should only be used in very short code blocks or loops.
Re: Why I'll never abbreviate a variable as long as I live
#95Earlier quoted context omitted.
If you read it and translate what he's saying to programming, you can glimpse a form of software that would make what people today call "readable code" seem as primitive as mathematics before the advent of decimal numbers seems to us. This is an extraordinary (and enticing and often advocated) claim that has, so far, failed to produce the extraordinary evidence. It says something that a person as concerned with notat…
I see no connection here to what I wrote, which has nothing to do with functional vs. imperative programming. I'm talking about names and readability in code. Imperativeness is a separate matter. One can easily have it without longDescriptiveNames, and although I don't have Knuth handy, I imagine he did.
Re: Why I'll never abbreviate a variable as long as I live
#96Earlier quoted context omitted.
I don't understand. Why would one submit a minified code for a review? A friend of mine used to work at a place where one of the coder actually used 'a', 'aa', 'aaa'...when naming variables.
I was joking. The example sort of looks like something that would fall out of minify -- although 'a' - 'z' would have to be used/visible in a scope before 'aa' would be generated as a name.
My guess is that the coder saw a minified code a took it as a standard or something.
Re: Why I'll never abbreviate a variable as long as I live
#97When hiring we ask for sample code from developers written specifically for the job application. We place a really high premium on readability. Occasionally we'll get code from devs that is very concise - not just abbreviated variable names, but complex long statements using ternary etc. I'll usually ask them to resubmit code and really focus on readability and it turns out fine. But I think there might be a misconce…
I'm sorry, how can verbose code impact performance???? Please elaborate.
So instead of
if (long.and(Complex(Expression)) && (other || long && expressions)
You use mandatoryConditional = long.and(Complex(Expression))
optionalConditional = other
otherOptional = complex && expressions
if (mandatoryConditional && (optionalConditional || otherOptional)
Now you have more names hanging around, and longer code, but it's better to read, especially if these conditional variables are named properly. Some people fear that this could negatively impact execution time, but I don't think it will have any noticable impact in modern languages.Another problem could occur where people verbosely allocate things, pre-computing and re-computing aggregate data structures, and a one-liner would've been more efficient since it goes over the same data only once.
Re: Why I'll never abbreviate a variable as long as I live
#98I was recently implementing a geometry algorithm which I looked up on quora. It was described using typical vector notation, using r,s . t,u. Since I referenced the algorithm in the comments, I decided to use these same variable names in my code. I think this is the right choice, but my code reviewer didn't. But he didn't click on the quora link. Why is okay for mathemeticians to abbreviate things but programmers? Is…
It's about as much work as writing the code in the first place, but it has saved me a lot of times when I or someone else had to go and work on it.
Re: Why I'll never abbreviate a variable as long as I live
#99Earlier quoted context omitted.
If you read it and translate what he's saying to programming, you can glimpse a form of software that would make what people today call "readable code" seem as primitive as mathematics before the advent of decimal numbers seems to us. This is an extraordinary (and enticing and often advocated) claim that has, so far, failed to produce the extraordinary evidence. It says something that a person as concerned with notat…
I see no connection here to what I wrote, which has nothing to do with functional vs. imperative programming. I'm talking about names and readability in code. Imperativeness is a separate matter. One can easily have it without longDescriptiveNames, and although I don't have Knuth handy, I imagine he did.
Re: Why I'll never abbreviate a variable as long as I live
#100Earlier quoted context omitted.
Historically, i wasn't even an abbreviation: It was the first variable name which would be assumed to be integer by FORTRAN compilers which implicitly assigned types to variables based on name. The choice was probably further influenced by longstanding mathematical tradition, which uses i and j as indices. (You could declare types and the compiler would respect it, leading to the old truism "GOD is REAL, unless decla…
I think the weirdest thing old Fortran did was to let you pass a constant by reference to a subroutine, which could therefore change its value.