| >A function is a "thing", you should rather compare it to an entity in the English language. It's more a verb that does an action on a noun. You can't express the concept with just a word. add one to number
>Why do we say washing machine instead of a home appliance powered by electricity used to wash laundry through the use of centrifugal force?Obviously there's no need to describe the plumbing behind the machine just the purpose of the machine is good enough. Everyone understands what a washing machine does as it's culturally a part of our language. If I lived in a civilization without washing machines and I had to implement it as a variable name in code I would call it "clothes_washing_machine" because of added clarity and no actual harm done with the extra word. >When naming things you need to balance descriptiveness with conciseness, a name is not a definition. Sure and I'm saying most people are wrong about where this "balance" actually lies. People place too much emphasis on conciseness. >As a rule of thumb, avoid specifying things that can be easily guessed, especially if they are right there in your function signature (!): I don't like readers to do any guessing at all. It's wrong to make assumptions that a guess that comes easily to me will come easily to my audience such is the nature of documentation and documentation as code. I want people to read my code like they read english. But that's just my opinion. def find_animals_in_pic(picture: Picture) -> List[XYCoordinates]:
I mean what's the benefit of shortening this. I'm looking at this function and I'm feeling nothing happened. You just did extra work.If I want to be nit, XYCoordinates should not be plural, List should contain many Types each called XYCoodinate. XYCoordinate(s) is better used as an alias for the entire list. Additionally my function only operates on cats, dogs and baboons. It does not operate on all animals. Someone can mistakenly use this function to try to find lions and tigers and bears Oh my! But that's besides my point. You attempted to shorten my function name while preserving meaning for which I totally understand the point you were trying to convey. What I'm saying is your changes are logically negligible. They do nothing to improve understanding of the program while trivially shortening things. Nothing practical occurred here. It's simply the scratching of an OCD need for more poetic names. |
I understand you prefer to be more detailed in your naming, that's fine, but in natural languages your names would sound unusual/verbose as much as they do sound unusual/verbose in Python.
You say everybody understands what a "washing machine" is therefore a short name.
Are you saying that when washing machines were still a novelty they should have been called "clothes-washing machines" instead? Unusual naming right? People do seem to have a distaste for long and overly-detailed names in spoken languages as well, don't you think?
And what's the point of a dictionary if names embed a full definition that leaves nothing to be guessed?
> Sure and I'm saying most people are wrong about where this "balance" actually lies. People place too much emphasis on conciseness.
Where to draw the line can be a matter of preferences, no intention of debating that, but people do tend to draw the line the same way whether they speak English or Python. No incoherent behaviour there.