Skip to main content

Naming Convention [Resolved]

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 ?

Question Credit: Goktug
Question Reference
Asked December 5, 2018
Posted Under: Programming
1 Answers

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.

credit: Kilian Foth
Answered December 5, 2018
Your Answer