3 ms·
I've always taken the approach of making variable/function/class names as verbose as they need to be. I do not use any sort of abbreviation in function or class
by scriptkiddy 10y ago
I've always taken the approach of making variable/function/class names as verbose as they need to be. I do not use any sort of abbreviation in function or class names. However, I will sometimes use abbreviated variable names or function arguments. For instance, if I had a function that searched for and returned an object that has a specific property from a list, I might use the name 'find_object_with_property'. The arguments might be 'list' and 'prop'.
It's been said many times that naming things is the hardest problem in programming.
- jimmaswell 10y agoAbbreviations are appropriate in methods/classes/variables often enough as long as they're unambiguous. Some common ones are Camera->Cam, Position->Pos, UI/GUI/HUD, and of course you wouldn't type out the full names of XML or TCP.
- rileymat2 10y agoI would argue that consistency in the creation of abbreviations is also important. It is a headache to take over a codebase written by several people who abbreviated things differently.
- scriptkiddy 10y agoI wouldn't have any problem with those abbreviations, I just wouldn't use them myself.
- diminoten 10y agoIf you're using an IDE, long variable names shouldn't matter due to autocomplete.
- scriptkiddy 10y agoAgreed. I use PyCharm for my day job, so I don't really have a problem with long variable names.