On The Number Two.
Ahhhh variable names.
I think I care much more about them than a sane person should. Today I’d like to share with you my opinion on the tendency of developers to abbreviate the word “to” to the number “2”.
What I’m talking about it using this:
var order2Refund = new Order();
In oppose to this:
var orderToRefund = new Order();
I’m on the side of using the entire word, because as a code writer we want our code to be as readable as possible, giving as much intent as possible.
If you’re used to the “2” abbreviation it is no mental jump for you to associate that to the word “to”, but for developers reading who do not have that connection, it is an unnecessarily wasted thought that could be better used solving a business problem.
People may say I’m being pedantic, but I really don’t see the benefit of this abbreviation. I mean sure, it’s one less key stroke, but the key that you’re now using is out of the most used area in the keyboard and probably not as deeply ingrained in your muscle memory – so I doubt very much time would be saved…. not to mention and grammatically incorrect.