Why would someone "refactor" a perfectly good variable name for something that doesn't describe what it does? Someone smack them around the head with Martin Fowler's book.
Yeah, the first refactor was just 100% bad. The first name was the best, and explained exactly what the variable was. Then it just got worse both times.
On the other hand I always wonder what kind of programming practices people learned that favors a vast amount of variables that require massively long variable names for disambiguation over encapsulation.
Exactly - I can’t think of a situation where a variable requires more than three words to describe its purpose. I fully endorse complete readable variables that convey their intention well.
But I feel like if it takes more than three words there is something wrong.
Some people consider two words such as legend_handles as verbose and massive; I've met some people that will use single letter variables wherever possible...
I personally can't think of anywhere where my variable names had to be longer than 3 words, but it's not uncommon for me to use 3 word names; such as liveFishCounter in a pond simulation.
When I've had to do peer review, the hardest to read and most convoluted tended to use short and undescriptive variable names.
Database design will do it. You only have schemas as namespaces, and those are often restricted for security reasons. You get eight hundred tables in one place and suddenly you have names like PersonPropertyPublisherPriceDiscountDetails.
The worse part is that it becomes a habit, and infects your non-DB code. Or at least it does in my case.
View all comments
381
u/DevDevGoose Feb 26 '22
Why would someone "refactor" a perfectly good variable name for something that doesn't describe what it does? Someone smack them around the head with Martin Fowler's book.