DEV Community

Discussion on: A short comment on comments in the code

Collapse
 
arnebab profile image
Arne Babenhauserheide

Code speaks to the machine and humans, comments only speak to humans. That’s why comments can always be easier to understand and give more context than code.

They may not always do that, and if the code gives the information sufficiently easy to take in as the comment, I prefer just having the code, but I spent the last years working on a codebase of which a part suffered from having no comments due to adhering strictly to clean code.

The parts with comments are always easier to understand.

Leaving out comments leads to code that replicates the comments but does not actually make a difference.

The main differences between the name of your function and a comment is that you have more constraints in spelling the function and that the function shows up in code-completion and at any place your function is used (which can be an advantage, but also adds more constraints).