Hard to Name
Sometime it’s hard to name a function. It is partly because of wordsmithing issues (we can’t always describe operations succinctly). That’s normal, and it is probably worth the time to bring up a problem with a coworker and maybe put some wear-and-tear on your thesaurus. Other times it can be a code smell.
Other times, it is because of violations of the basic characteristics of good function design as described in Behold! The Function!. A partial function, a function with more than one operation, or an ill-conceived function could be hard to name.
But there are other times when the problem is that the function is merely a wrapper or adapter for another function, built for convenience. These things can be called “add-a-file-to-the-cache-with-the-add-a-cache-function-after-checking-that-the-checksum-is-correct”, but that gets tedious to type and tedious to read. Merely finding names which mean essentially the same thing, colored for special cases of adaptation an be difficult and names can become arbitrary and ugly. In most cases, suffixing or prefixing suffices.
Other times functions exist purely as a refactoring to take a chunk of repeated lines out of two other functions. Ahh, here is an interesting bit. Once and Only Once is a very good thing, and I have full agreement with it. But if it is hard to name the extracted commonality, for reasons other than wordsmithing, then it may be that it was extracted into one function when it should have been two, or it hasn’t been fully extracted — it is a ‘middle’ bit instead of an operation, or it may be that it was extracted from two ill-conceived functions which each were hard to name and explain. After all, not all patterns are good.


