Many developers treat variables as a place to simply dump a value, without spending much thought on picking a name. This is unfortunate, as proper naming of your variables can greatly increase the readability and maintainability of your code. A name should tell you why a variable exists, what it does and how it is used. Here are 4 practical rules for picking variable names.
lv_myvariable - Don't do this
Avoid meaningless abbreviations
Do not worry about using more horizontal space, descriptive variable names are far more important than saving a few keystrokes when typing a variable name. Of course there are cases when abbreviations are perfectly fine, but in general it is better to be as descriptive as you can.
iNErr - Meaningless abbreviation
iNumErrors - 'num' is a common abbreviation
sCstmrNm - Don't remove letters to shorten the name
sCustomerName - No abbreviation necessary
So when is a variable name too long? When there is a shorter name that will allow for better code readability.
sServiceUniformResourceLocator - Dont spell out URL
sServiceUrl - Widely used abbreviations are fine
Use concise terms, that accurately describe the meaning of your variables. vague terms like 'data' or 'info' may signal you are having trouble finding an appropriate name.
var aData; - I have no idea what this array is for
var aSelectedRows; - Easy to understand
Write booleans as predicates
To make booleans easy to read in statements, we can write them as follows: