Why I hate abbreviations in code
I am pretty relaxed and pragmatic when it comes to coding standards: As long as there are sensible and consistent conventions that have been agreed on by reasonably sane people, I am generally OK. However, there is just one thing I just can't let go - and that is abbreviations.
Abbreviations are an excellent way to arbitrarily add in complexity. Have a look at the following example:
// Here is an example of a JavaScript function with abbreviated naming
function calcp(v, p) {
return (v / 100) * p;
}
// Here is the same function with verbose but straightforward naming
function calculatedPercentageOfValue(value, percentage){
return (value / 100) * percentage;
}
// Which one do you prefer? I would choose the verbose version every time - its purpose is immediately apparent - you do not need to do any mental sudoku to work out what it does. When abbreviated functions get composed together, the cognitive load caused by the complexity can really ramp up. The only time I feel abbreviations are acceptable is if they are part of the language's culture: For example fn is commonly used in JavaScript as a variable name to store a function - this is OK as it is widely used. So, unless you really enjoy making colleagues or your future self's life harder than it needs to be - avoid abbreviations and favour straightforward verbosity.