- 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
// format the hard drives
NuclearBomb.Launch();
Admin
Admin
Yep, the WTF is insisting on commenting every line - they should be as self-documenting as possible.
To be fair, that comment is possibly highlighting a bug in the application - why has the timeout changed from 1 to 30 days?
Having said that the comment is a little terse and not a lot of use in understanding what is being attempted at that point.
Also, the comments should be updated before the code, as they should be viewed as part of the documentation (of the specification and how it is being achieved), rather than just stating what the code is doing.
Admin
24rs? 24 hours, 24 seconds, or 24 of something?
Admin
Admin
Maybe an 'r' is an obscure unit of time equal to 1.25 days
Admin
Document 'why', not 'what'.
And self-documenting code is a myth. If code could be understood just from reading the code, then computers could do our job. But understanding code just by reading code is a violation of Rice's Theorem.
Admin
Understanding the WHAT is not a violation, (as mentioned previously) it is the WHY which represents the challenge. [NOTE: In addition to reading the code, one must have an understanding of the execution environment]
Admin
See how convenient it is to see that the comment is wrong, because it's right by the line of code? It would have been much harder to catch that documentation mistake had the comment been included in some document or paragraph at the top of the page.
Admin
r is not an obscure number. It is actually a speed. The speed you have to go without being late by in this case 24.
Admin
Obviously not all code can be self-documenting. Notably, code implementing complex algorithms where the result matters more than the method. That said, most code can and should strive to be self-documenting.
Admin
"If code could be understood just from reading the code"
That is literally the entire point of high(er) level code though. It's why we no longer write in assembly language.
Admin
Well put ooOOooGa
Assuming that a higher level language or "higher level coding" (whatever that may mean) mitigate complexity is misguided.
There is some truth to the language of domain vs language of design debate, but at the end of the day developers spend a lot of time in a language of design framework, which is most assuredly not self-documenting.
Admin
When I hear “self documenting code”: Sometimes it seems obvious that some code should be there, but there is a valid and less obvious reason why it isn’t. And code that isn’t there can’t document itself. It needs comments.
Admin
I don't understand how people can get so hung up on when and how to write comments. It's easy. Anyone who has ever had to write a paper on anything should have the instinctive undersatnding how to do it. Just think of your code as the main body of text and your comments as the footnotes.
Admin
So something else which can be traced back to "management" who have heard that comments are good, so decide comments for every line will be gooder.
Admin
several comments remind me of "dover cheetah" from an old comic "suburban jungle": "hello there." "set greeting="hello"." blink blink "so, you're a computer programmer?" "statement=true."
Admin
Anyone who says their code is self-documenting, tell me that again after you have to come back a year from now, figure it out and make a change.
That said, what aggravates me the most is people who add documents to explain the things I could figure out from reading the code, and then don't bother to explain the things that are hard to figure out.
Like I literally once came across a line of code that said:
Like wow! Thanks for that helpful comment! I had forgotten what a plus sign does. But he gave no explanation of what "x" was or why he incremented it here.