If there’s one thing I’ve learned over my years of development, through reading my own and other peoples’ code:
NEVER try to save on keystrokes for identifiers
Please, please don’t write p instead of product, don’t write fl instead of fileLocation. I may be preaching to the choir, but a random look at code shows that it bears repeating.
There are many possible reasons to use abbreviations instead of the full name of things:
- long and complex names moduleNamesAndLabels
- it doesn’t fit on my editor window
- I’m practicing code golf in my day job
- I can’t be bothered and haven’t had my coffee yet
In my experience attempts at typing less (in this instance) will result in blood and tears later. It’s an implicit part of the imperative Code for the maintainer
Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live.
On the practical side, you can fix your workflow so you won’t be tempted. All sensible editors have autocomplete facilities. In vanilla vim Ctrl-N will get you autocomplete. The snippet below pasted in .vimrc will change Ctrl-N to tab (one keystroke less!) and will give you the dictionary to boot (adapt the location of the dictionary to your system).
1 2 3 4 5 6 7 8 9
I’m reasonably sure emacs, sublime text and certainly IDE will have equivalent features. So laziness is not an acceptable excuse not to use the full name of things.
Do you want to be exposed to code that looks like this?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
(bonus points if you guess which project this is from :) ) (no cheating)
Coders of the world, type it like it is.