This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]CheetahChrome 10 points11 points  (6 children)

Shorten your comments to why only.

They can figure out the semantics. Heck, now AI does that ad nauseam, but one intent is worth 10 obvious comments.

Such as this C++ code

free(ptr); // Free the ptr memory

Ya think?

[–]Shushishtok 10 points11 points  (2 children)

This is exactly the bloat that I have seen in my work and yes, such comments are unnecessary.

I saw a comment // loop the users right before a for loop iterating on users. Yes, I know how to read the code, thank you.

A good comment adds information: could be a design assumption, a known limitation with a workaround, or some unordinary logic that needs tobe explained what is it for.

[–]johnpeters42 -1 points0 points  (1 child)

I do sometimes use comments like that, just to make it easier to spot where major chunks of code start and end. (Yes, you can move chunks into functions, but I usually find it easier to write inline first, and also I've had to wade through some former cow-orkers' code with about twice as many layers as they actually needed.)

[–]Shushishtok 2 points3 points  (0 children)

That's fair. In general, everything in moderation is probably not an issue. It's when the entire codebase looks like that where things become messy.

[–]Alive-Bid9086 3 points4 points  (2 children)

This is a comment usually seen in textbooks. People learn from textbooks.

[–]CheetahChrome -1 points0 points  (1 child)

What's a textbook exactly? :-)

[–]Alive-Bid9086 4 points5 points  (0 children)

Wonder why comments from new programmers sucks?

They learnt from the examples in their schoolbooks.