This Overly Long Variable Name Could Have Been a Comment | Jonathan's Blog
Programming
41
Posts
27
Posters
0
Views
-
The biggest problem with comments is that they can become outdated. If you change code but forget to change comment you introduce very dangerous situation where they become not only not useful, but also misleading.
If you rely on variable names, you've got a single source of truth, one thing to change at a time. Information updates itself.
The same thing can be true about variable names, and it is often more time consuming and error prone to change a variable name to match its new meaning than to simply update a comment. Especially if the variable name is public facing through an API or library then there is a huge cost to change the name everywhere that might reference it.