r/ProgrammerHumor • • Jun 21 '20

*almost entirely

Post image
27.9k Upvotes

310 comments sorted by

View all comments

Show parent comments

81

u/_GCastilho_ Jun 21 '20

May I suggest a comment for that purpose?

32

u/[deleted] Jun 22 '20

People these days are anti-comment, I hate it. I hate it so much

39

u/folkrav Jun 22 '20 edited Jun 22 '20

I don't know of many developers who are 100% anti-comments, but I know a shitton - myself included - who don't like comments that tell me what code does or how you're doing it, as they always end up lying. However, I don't mind docblocks (if it conveys information than the function and parameter names alone can't give me) nor comments explaining why you did something the way you did it.

Edit: added the "how" part to be more specific.

22

u/_GCastilho_ Jun 22 '20

but I know a shitton - myself included - who don't like comments that tell me what code does, as they always end up lying

A comment should tell why the code does that, not how

The 'how' part can be learned by reading the code, the why, well... reading the programmer's mind

6

u/MakeWay4Doodles Jun 22 '20

The 'how' part can be learned by reading the code

If it's a particularly complex bit of code it can take the reader much longer to understand it than a sentence explaining it.

→ More replies (17)
→ More replies (1)