When we determine names for the variables, there are two important issues that the people mention:

  1. The variable names must be explanatory. For the sake of this, their names can be long.`

  2. The variable names summarize main purpose briefly; they cannot be long. Long names decreases understandability.`

Which one of these should be take into consideration ?

closed as primarily opinion-based by gnat, Thomas Owens Dec 5 at 15:14

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Both! (and neither) – Ewan Dec 5 at 15:12
  • The guidance on the "opinion based" closure option is "Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise." Given that the one answer clearly fits the "facts, references, or specific expertise." rather than "almost entirely based on opinions", I believe that @thomas-owens is wrong to close this, so I'm voting to re-open this. – David Arno Dec 6 at 9:33
up vote 4 down vote accepted

That's not quite the reason usually given. Long variable names increase understandability because they can explain the purpose of a variable more explicitly. temperature_of_the_main_reactor explains more than just temparature.

The point is that long tokens decrease readability - they take longer to process, and the increase is super-linear (it takes more than twice as long to read a 20-character identifier than a 10-character one). Therefore there is a trade-off between expressiveness and conciseness, and the sweet spot is somewhat of a subjective value, since people read in rather ideosyncratic ways. This is why there is so much debate about the right way to name variables.

As usual, dealing with a trade-off requires you to follow both principles and decide how much weight to give to either of them.

  • Thank you so much for your answer. What I try to mean with understandability is actually code understandability, that is readability. – Goktug Dec 5 at 15:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.