[Python-ideas] Objectively Quantifying Readability
Jacco van Dorp
j.van.dorp at deonet.nl
Tue May 1 03:00:44 EDT 2018
I must say my gut agrees that
really_long_identifier_names_with_a_full_description don't look
readable to me. Perhaps it's my exposure to (py)Qt, but I really like
my classes like ThisName and my methods like thisOne. I also tend to
keep them to three words max (real code from yesterday:
getActiveOutputs(), or at most setAllDigitalOutputs()). I also really
dislike more than 3 or 4 arguments.
A question for another type of science would be, do I agree with this
study because it agrees with me ?
It should be noted that the snippets used were short and small. This
might cause a bias towards short identifiers - after all, if you only
got 3 to keep track of it, they're more likely to be distinct enough
compared to when you have 20. I couldn't give a source, but IIRC
people can hold up to around 5 to 7 concepts in their head at one time
- which means that if you got less identifiers than that, you don't
remember the names, but their concepts.(further reading shows this is
supported with their strongest negative correlation - # of identifiers
strongly decreases readability.). Compare it to RAM - it's only big
enough for 5 to 7 identifiers, and after that you have to switch them
out to the harddisk. *nobody* wants to code that does this switching,
and our brains don't like running it either. I think this is one of
the main reasons list/generator comprehensions increase readability so
much. You can get rid of 1 or 2 variable names.
More information about the Python-ideas
mailing list