DEV Community

Discussion on: A short comment on comments in the code

 
arnebab profile image
Arne Babenhauserheide

You asked, whether it would not be better to add a comment. No, it would not. The function name is the information that shows up in code completion and is the first thing people see. If you can, you should make sure that it reflects what the function does.

You might still be forced by your tooling to add a comment instead, but that’s then a question of tooling not of what’s the right thing to do.

Also you may want to add a comment anyway, because the three-to-five words you use in a function name are often not capable of capturing the more subtle information you need when using the function. Look at the Javadoc of some of the Java Collections methods.

You could make the name much longer, but then it is polluting the code where it is being used with information you only needed when writing the code, but usually not while reading it, because there you can usually assume that the original author made the right choice.

(Sidenote: your argument would be much stronger, if you asked what to do for public API of libraries. There it is impossible to change the name of the function where it is used, because you don’t control those parts of the code).

Thread Thread
 
tosey profile image
Tosin Seyi

Read my comment very well. It seems you don't understand it. Plus, you're even contradicting yourself bro 🤔 .

Thread Thread
 
arnebab profile image
Arne Babenhauserheide

No, I’m not contradicting myself. I’m telling you that you make a weaker argument than you could.

In my first message I answer your general claim (what would you rather do? If I can, I’ll refactor; depending on the IDE that can be as simple as a single keyboard shorcut). In my second answer I add the limitations and fine details that must be checked to take a good decision.

Don’t expect a simple yes/no answer when it comes to comments.

Also I’m not your bro.

Thread Thread
 
tosey profile image
Tosin Seyi • Edited

And my reply then was "Is it everybody that uses IDEs?" Most developers I Know use vscode and do they keep replacing the function name in every file they used them when they add new features to it? This is my main point. You can speak for yourself but don't try to speak for everybody. Because you can't.

And also, it's your choice whether you are a bro or not.

I won't reply you again. Because it seems you are proving obstinate.

Thread Thread
 
amabe_dev profile image
amabe_dev

I agree with @arnebab

And my reply then was "Is it everybody that uses IDEs?" Most developers I Know use vscode

VSCode has the features required to rename the function. Even vim has it if well configured.

If people choose to code with a dumb editor, they are not using adequate tooling to make good software.

And if you choose not to use the features of the editor then I can't argue that you will have to find hacks like generic function names and comments. But that code will not be as clean as it can.

Thread Thread
 
arnebab profile image
Arne Babenhauserheide • Edited

I answered you “You might still be forced by your tooling to add a comment instead, but that’s then a question of tooling not of what’s the right thing to do.”

That’s for the ones without working rename tooling.