Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
That is an overly passive-aggressive stop sign. It has its purpose and the ones indirectly responsible very well know why it is there...
Useless comments in code on the other hand is mostly caused by compliance theater or gets written by code monkeys. -
Grumm18222y@dowhile
{// start block
//Empty line
//if
if (var = true)
//if var = true, do this
function(); //call function
//else do this
else
//call other function
otherFunction();
//Empty line
}//end of block -
hjk10156962yWhat I did used to do but got some comments on was this with early returns and loop breaks/continue:
While condition {
If other_condition {
Statement;
Continue;
} // else
Statement;
Statement;
} -
Earu5632yUnless you’re doing something complex or a bit weird IMHO you don’t need to comment HOWEVER a documentation is always needed.
-
Always was a staunch defender of comments for intent.
We all know how to read code, it's unambiguous. (May be more or less readable, but if it compiles/runs, it's readable). Don't comment what the code does.
It's what was your reasoning we can't read. Put it in a comment -
@hjk101 If you really feel the need to mention that that indeed is an alternate code path in a comment - then just replace the continue statement by turning the other code path into an actual else branch.
👀 guilty. Kinda.
joke/meme