DEV Community

Discussion on: "Do not comment on your code, it should be self-documented". Well... I don't agree.

Collapse
 
brense profile image
Rense Bakker

The function name should convey its purpose. Same for the params. When I see a docblock above a function it usually means one of 2 things. 1. The comment is entirely redundant or 2. The function doesnt have single responsibility.

Except in config files I've never seen a comment that told me more than the code itself. The inverse however is true. I've seen a lot of outdated comments that no longer convey the purpose of the code, or even comments that flat out lied, because they were copy pasted from somewhere else and not updated properly.

IMHO docblocks make devs lazy. Focus on writing good clean code (there are books about that if you're interested) don't waste everyone's time writing comments ;p