DEV Community

Discussion on: Do Code Comments Deserve a Special Spot or Can Well-Written Code Speak for Itself?

Collapse
 
velydev profile image
Vely

Probably the most important comment you can make is to first state what the unit of code does, or what it's supposed to do. For instance, if you write a function, state what is its purpose and how it interacts with the rest of the application.

That may sound obvious, but I've seen so much code where the author explains how the code works, even down to minutia, but there's barely any mention of what it does, if any at all. Once you know what the code is supposed to do, then it's much easier to follow its internal mechanics.

Collapse
 
eddykaya profile image
Eddy Bobbin

Imho the information about what a function does is exactly the thing I would not comment. The name of the function should be clear enough to state what it does.
However, often the context why a function does what it does is way more important for the next developer to understand, especially if he stumbles over that function half a year later (where you usually have no clue about this specific code).