| The problem with your analogy to English is that you're comparing the wrong things. A function is a "thing", you should rather compare it to an entity in the English language. Why do we say washing machine instead of a home appliance powered by electricity used to wash laundry through the use of centrifugal force? When naming things you need to balance descriptiveness with conciseness, a name is not a definition. As a rule of thumb, avoid specifying things that can be easily guessed, especially if they are right there in your function signature (!): def find_xy_coordinate_of_dogs_cats_and_baboons_in_picture(picture: Picture) -> List[XYCoordinates]:
I'd refactor it to: def find_animals_in_pic(picture: Picture) -> List[XYCoordinates]:
|
It's more a verb that does an action on a noun. You can't express the concept with just a word.
>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.
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.