4 ms·
Short names are easier to read, because they fit on fewer lines. Doubly so if the statement fits on one line.
by patrick451 4y ago
Short names are easier to read, because they fit on fewer lines. Doubly so if the statement fits on one line.
- onion2k 4y agoShorter names aren't easier to read if you have several similar names used in close proximity. More characters can reduce the congruence and make it easier to differtiate between names. I agree about fitting things onto one line though. It's usually better to break things up into to several short one line steps rather than have a long multi line statement.
- philipwhiuk 4y agoI tend to think length should be proportionate to broadness of usage within the file/project If it's used in lots of places, go for MAXIMUM_MONSTER_DENSITY_SCORE_MULTIPLIER If it's used in a single file/function, then maxDensityMultiplier might be okay. (You can infer the rest from context). If it's used in a very confined section, then multiplier. If it's a loop variable then, sure use m.
- ziml77 4y agoMore characters can make it harder to differentiate names. The longer the name is, the harder it is to see it as a single unit while reading. Also, if the long names cause many extra lines, it becomes easier to lose context from the extra distance one moves down the document while reading.
- Shorel 4y agoIf they all start with 'factory', sure. I would be a long name that doesn't add information that helps differentiate between different variables.
- deleted 4y ago[deleted]
- oriolid 4y agoA special case is when you're working on something mathematical. The articles and textbooks that describe the algorithm are all using single characters do represent things, and it is just additional mental load when you read the code and algorithm description together and have to translate between descriptive names and the paper's terminology all the time.