by Carpetsmoker · 7y ago · 0 comments
I think what is intended in general are comments in the form of:
// Start the loop.
while ( have_posts() ) : the_post();
[..]
// End the loop.
endwhile;
And yes, that is an actual example from a real codebase.This is an extreme example, but quite a few of comments I see are very redundant. Sometimes comments are useful to split stuff up, but stuff like "start loop", yeh nah. It's just a random stray comment, probably as an artefact from when the author was gathering their thoughts and/or took a break.
Even worse are comments that are just confusing, or don't match the code.
I've done some literate programming, and I find it interesting for certain types of programs and/or if you're struggling with something. But I think that for a lot of stuff it's redundant.
In my highschool introduction to programing class, we were for a long time required to comment every line of code. Examples given by the teacher were all this type of comment.
I've no doubt it put the wrong idea into some students' heads.
So often when I see this I wish people would have used another function. Its hard to argue that a function which requires splitting things up using comments is "doing one thing".
Way too many people here are confusing comments with documentation.
A great approach to this is Python's docstrings, which parse to the naked eye as comments but can be rendered into proper documentation.