- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I hope origional is spelled consistently throughout the code, or there will be other problems.
Edit Admin
if(frist) ;
IOW, even the comment is empty. :)
Edit Admin
More useful comments (I hope) ...
I almost wonder if the first one
if (!checkAndDelete( ...
isn't a warped attempt to call a method that has a return value and swallow the return value. Yes, darn near every language nowadays will swallow a return value. In Ye Olden Tymes that was less true. Of perhaps theif(...)
construct was a way to stop a warning or lint message about an unused return value. But that doesn't explain the useless negation.Of course the real truth is probably that there used to be a body under the
if
, then requirements changed. But the method call in theif
predicate has side effects, so of course it needed to stay. Under the misguided principal of "minimum possible changes ever; refactor never" they just removed the body leaving theif (...)
exactly as it was.Admin
I can guess how the first one happened. Presumably
checkAndDelete
both does the deletion and rerurns a value representing the result of the check (I guess whether there was anything to actually delete?). At one point, this return value was used to conditionally run some extra code - and at some point, that additional code became unnecessary.At that point, some less bright team member presumably first tried deleting the whole block, but found the code broke (the side effect of the deletion being important). So they decided to keep the
if
and just remove the body - as opposed to the less confusing alternative of just leaving thecheckAndDelete
call as a single statement, not caring about its return value.Admin
Aargh, the post above appeared while I was typing. Still, great minds and all...
Admin
"$mail->SMTPAuth = false; // turn on SMTP authentication"
This is certainly from PHPMailer a widespread email utility for PHP. I probably even have this exact line in my testing server copy of the code. The value gets set to "false" or "true" depending on how code is being tested.
Sure, the comment (which comes that way with the PHPMailer package) should be "// turn SMTP authentication on or off", but that's pretty picky when the point is so obvious to anyone actually using the code.
Admin
If you can code — and not make your code your master; If you can comment — and not make the comments a shame; If you can bear to have your flag for authentication Set by knaves in mockery of the same; Empty line
Edit Admin
Be careful with this rationale. If "it doesn't matter because it's obvious", then what's the rationale for doing it at all? That's actually what everyone is trying to say when they say that the comments shouldn't simply repeat the code. If all you have to say to the next person that reads this code is what it already says... then don't say it again. Leave the comment out.