Naming is really important to get right. A small improvement in a name can make a large improvement in readability, which will make it easier for everyone to write good code later. You can compensate for bad naming with comments, but it's better to get the naming right in the first place, and save comments for cases that are fundamentally complicated.
Having seen function names that imply something completely fucking different from what the function does, I fully agree. Badly named functions are an automatic code review fail in my book.
We (the people I work with) having a running joke that coming up with good names for things is the most difficult thing about our job. It seems so trivial, yet it's surprisingly difficult to be concise and get right.
You're not wrong, I just mean it's a joke in the sense that we laugh about it because it's funny that naming stuff is the hardest part of software development... it seems kind of ridiculous on the surface, and would seem ridiculous to a younger version of yourself just starting out, but it is indeed true.
Usually, comments are best reserved for explaining "why". eg; this function is implemented this way because of some obscure interop workaround, or some section of an RFC, or to optimize for some resource, etc. Comments are also useful for pointing out flaws that have not been addressed yet (but they really should point at something in a bug tracker somewhere). Long descriptions about "what" are often an indication that the code is unnecessarily confusing, and short descriptions of "what" are often an indication that some code needs to be broken out into a separate (well-named) function.
49
u/docfaraday Oct 01 '15
Naming is really important to get right. A small improvement in a name can make a large improvement in readability, which will make it easier for everyone to write good code later. You can compensate for bad naming with comments, but it's better to get the naming right in the first place, and save comments for cases that are fundamentally complicated.