When 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.
Why I'll never abbreviate a variable as long as I live
81–90 of 111 posts
Re: Why I'll never abbreviate a variable as long as I live
#82I definitely prefer more verbose names to abbreviated ones, but I'm not sure that never abbreviating a variable name is the right way to go either. Surely there's a middle ground between `Ttpfe` and `timeOfTenPercentHeightOnTheFallingEdge`?
Use context. If you can't, refactor so you can. If you can't, well, you're SOL and stuck with timeOfTenPercentHeightOnTheFallingEdge. Edit: e.g. if all of your variables are "timeOfTenPercentHeight...", cut that part out of the name. Full names can be just as bad as abbreviations - e.g. if they're all "timeOfTenPercentHeight..." then they all start to blend together.
times.tenth.fall
times.tenth.rise
Hopefully, they aren't using some ancient version of FORTRAN.My first paid work in the 80s was in a language with 8 or 10 character long names, depending on use, with only scalar values outside of ISAM tables. One compiler variant extended that with arrays (but not nested arrays). You had no choice but to make some weird names.
That said, when I started doing ANSI C with 32 char names, I felt like I had failed when I needed a variable that had to be that long to explain what it did. Either it had too broad a scope, or should have been bundled in something else (record/struct).
Re: Why I'll never abbreviate a variable as long as I live
#83Great writeup, full of sharp details. In the 90's I worked on a FoxPro application, also for DoD. My boss, a retired Navy Captain, used very terse variable names, partly because he was a hunt-and-peck typist, and partly because earlier languages allowed only two-character names. But FoxPro allowed variable names of any length. However, it only recognized the first ten characters. To my boss's chagrin, I often used na…
Hearing that absolutely terrifies me like?? Silently allowing names to collide in that way just sounds ridiculous to me.
Re: Why I'll never abbreviate a variable as long as I live
#84Great writeup, full of sharp details. In the 90's I worked on a FoxPro application, also for DoD. My boss, a retired Navy Captain, used very terse variable names, partly because he was a hunt-and-peck typist, and partly because earlier languages allowed only two-character names. But FoxPro allowed variable names of any length. However, it only recognized the first ten characters. To my boss's chagrin, I often used na…
Hilarity ensues...
And, yeah, I also did a lot of XBase in the late 80s, though usually "Clipper", rather than "Fox".
Batch files made a decent build process, and you could be disciplined with regular arc/zip files for source - not too unlike "make clean" and svn. We certainly had a lot of cruddy manual processes otherwise back then, though.
Re: Why I'll never abbreviate a variable as long as I live
#85Earlier quoted context omitted.
Whenever we interview a candidate, the one thing we give high premium on is structure, the rest come next. bad variable names, long complex code...can easily be adjusted . If the candidate doesn't have a good understanding of how to structure a code (what goes where, for what purpose, separation on concern...), it'll take much more effort to teach that candidate than to teach the bad variable namer. Properly structur…
"I ran the code through minify, but it's bigger now?!?"
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
#86Re: Why I'll never abbreviate a variable as long as I live
#87May I recommend checking out Rob Pike's document for a counter-point http://doc.cat-v.org/bell_labs/pikestyle I think that his variable names section is utterly ridiculous, but it's a relevant read from a relatively prolific person, so worth sharing.
While many of the Bell Labs guys didn't much like Pascal, Turbo Pascal managed to address almost all of the complaints I've ever seen, while preserving the good parts of Pascal (or Modula???).
Java must look irredeemable to the Bell Labs folks, though. Perhaps it is: UglyNames; limited structured constant literals; still too clunky lambdas for callbacks.
Re: Why I'll never abbreviate a variable as long as I live
#88Heh. When I first learned to code as a kid, a variable was max two characters (the first of which had to be a letter A-Z and the other could be a letter or number).
Ha, you're right. Commodore BASIC, probably? (written by Microsoft, I think.) I do remember at some point having access to a language with less restrictions on variable naming, and thinking, "wow, that's so amazing"
Re: Why I'll never abbreviate a variable as long as I live
#89I 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…
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…
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 notation as Knuth used mathematical notation for the analysis of algorithms and a primitive imperative machine language to describe behaviour.
Re: Why I'll never abbreviate a variable as long as I live
#90I 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…
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…