3 ms·
> A 20 character name doesn't do any damage if it communicates the correct point. That depends on the context. If the function is the highest level task called
by tomxor 6y ago
> A 20 character name doesn't do any damage if it communicates the correct point.
That depends on the context. If the function is the highest level task called infrequently (as in your example), then long highly descriptive names are completely fine.
If this occurs at every level, all the way down to the building blocks it absolutely, severely affects legibility of the entire code base - it is literally a multiplier of code size, in the worst case of "all the way down" it's some kind of power function.
This barely fits on a line:
(a leftmultipliedbyright (a leftsubtractedbyright 1)) leftdividedbyright 2
Yet it's a simple polynomial that should just be a(a-1)/2, probably part of a larger expression, now the other parts will end up on other lines (because no one writes 500 char width code), the effect is artificially spreading code thinly - this destroys locality and legibility.
You would be right to point out my example is extreme and absurd, however operators are functions, they only use different, implicit syntax. Many intrinsically complex pieces of code must create their own domain specific building blocks at a slightly higher level of abstraction that are much like operators, and this is the place for extremely short function names (think vector libraries), as such a commonly used building block it is unreasonable to expect each reference to fully and explicitly express the functions purpose.
As with all of these types of things, there is a balance, I am arguing _for_ balance, not suggesting all names should be single letter or single word - but that they have their place. However in my experience very long names are far more commonly due to thoughtlessness, they include excessive redundant context and at worst even grammatical words.
- Geminidog 6y agoClearly for algebra you want to use algebraic notation because the conventions of algebraic grammar are suited for those tokens. You're right context does matter. I'm more referring to naming as a means of communication. If your function is not intended for use as an algebraic operator and it does some complex operations like extracting the x y coordinates of the locations of dogs cats and baboons from a picture it doesn't hurt to place that entire description into the function name. It doesn't hurt to make the function name grammatically correct either as it certainly doesn't hurt when you try to communicate the same point in English. >As with all of these types of things, there is a balance, I am arguing _for_ balance, not suggesting all names should be single letter or single word - but that they have their place. However in my experience very long names are far more commonly due to thoughtlessness, they include excessive redundant context and at worst even grammatical words. I agree with balance. What I'm arguing here is that our general intuitive sense of what is "balanced" is actually off. People think "find_xy_coordinate_of_dogs_cats_and_baboons_in_picture" is an ugly function name and needs to be shortened but there is actually nothing logically wrong with it.