4 ms·
"from_file", "by_name", etc. are fairly needless here. Most people are apt enough to grasp the first argument relates to the last word of the function name. Use
by BlargMcLarg 6y ago
"from_file", "by_name", etc. are fairly needless here. Most people are apt enough to grasp the first argument relates to the last word of the function name. Use properly named variables so a summary can take care of it, or only omit the noun, "get list of profiles from".
Get itself is a terrible prefix and could be omitted, especially if you keep "from". "list_of_profiles_from(X)" isn't any less clear. Alternatives like "read_list_of_profiles(file)" exist.
"List_of_profiles" can be changed to "profile list". You already did it with "concatenate_profile_lists", showing inconsistency. Alternatively, depending on the context, "list" itself can be omitted entirely, and just state "profiles".
"merge_married_profiles_into_list_of_pairs" can arguably be shorted to "merge_married_profiles" depending on IDE and language: that last bit should be clear from the returned value. Even without, it can still be shortened to "pair_married_profiles", as the context should make it obvious if we look for more than 1 married couple, there will be some kind of collection. Additionally, your naming has one problem: "merge_married_profiles". With all the verbose naming, it is still not clear what "married profile" is. I'll assume it means "pair profiles of married couples", where you might as well say "pair_profiles_of_married_couples".
>Programmers like to think they're smart and original.
It is because they think to be smart and original, they fall into the trap of overly verbose naming. Not from a lack of it. Have you looked at a legacy Java code base? Many of them can be slashed in half just by renaming variables to something that keeps the meaning, or draws meaning from the context very obviously. These guys are going against their own mind's natural ability to read context, or worse, conditioned themselves to learned helplessness.
- Geminidog 6y agoYou're right some of the information is needless. But who cares, if a function communicates it's point it doesn't matter whether I prefixed 'get' to it or not. It's completely irrelevant. I'm saying that a 20 word function or a 10 word function doesn't matter as long as it communicates the point clearly. You say Many function names can be slashed in half and I say there's no need to slash any of those functions in half. There's no point other then this ocd need to come up with the most elegant name in the universe. But my argument goes even deeper then that because in fact humans cannot apply the logic you presented to other languages outside of programming. Take this function name: get_the_amount_of_water_in_the_bucket The function name is grammatically correct, but it offends your eyes because of all the wordy and unnecessary information I totally get it. What I don't get is if I tried to communicate the same concept to you in english you aren't complaining? Get the amount of water in the bucket. Actually let's apply your logic to English let's make it more concise and save screen space and make it less verbose. Bucket water amount. You have a task for your friend to get that water amount and instead of saying a proper sentence you point at the bucket and say the above. Efficient yes, but your friend now thinks you have brain damage. Therin lies the contradiction because for some irrational reason humans actually prefer the verbose form of english communication over conciseness in code. It doesn't hurt to have some proper grammer or unnecessary adjectives in an english sentence and it doesnt hurt your programming language either. That is my point. Profile_list vs list_of_profiles doesn't matter. Both are understandable. Maybe your version saves memory but who cares. It doesnt do any logical damage to the code. You only want to shorten things because of ocd because clearly no such desire exists when people write things in grammatically correct English.