Variable Naming Conventions
The cluster debates the use of short, single-letter variable names versus longer, descriptive ones in programming code, focusing on readability, maintainability, and contextual appropriateness like math-heavy vs. business logic.
Activity Over Time
Top Contributors
Keywords
Sample Comments
Why do you hate variable names longer than 4 characters so much? :b
eww, single character variable and function names make me ill
I’d love to understand the rationale for preferring extremely short variable names.
I always thought it's the same reason as when doing math on paper starting in elementary school you'd call things x, y, z, h, w, w2... etc. instead of triangle_width... etc.In math'ish problems naming/algorithm (noise ratio) needs to be kept low, otherwise you can't read through it.You want to elevate symbols between type/vars in reader's attention (what's happening) as opposed to being detailed in naming (which is less of a problem to recall).It&
haven't you ever written code with single letter variable names and it makes sense to you? and then been forced to read somebody else's code with single character variable names and found it completely inscrutable? this is just that on (a lot of) steroids
Might help understanding if the author used ‘meaningful’ variable names…
Can we collectively move on from single character variable names?The code examples are full of variables like "q" "a" and "v" -- it slows down everything as we must grok the surrounding statements like some kind of Rosetta Stone to interpret what "a" could possibly be in this context.Please fix it.
If you're in an abstract/general mathematical function, then sure: single letters. If you're doing more business logic kind of stuff (iterating through a list of db/orm objects or processing a request body) then the names should be longer
entirely_too_long_variable_names -> I prefer very long variable names which are self-explaining and easy to grep. Abbreviations make code less consistent and less greppable. Also what's the point of making shorter variable names if you need a comment to explain what it's doing - or worse I need to email the author to find the answer. A variable name should be the minimal representation of the role of this variable, but without cryptic shortcuts or abbreviations.
I've written code with single letter variable names lots if times! But later on it most certainly does not make sense to me.