- 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
"Oh, my God, we forgot to comment the code!"
"Don't worry, we'll have the Indian Outsourcing company read each function and describe it."
I've found that writing good documentation doesn't come naturally to a lot of people. Especially people who haven't written real programs using real API documentation across a range of platforms/APIs. You have to have a certain kind of creativity to imagine what a user of a function would actually need to know, if he didn't already have the knowledge that you have yourself about the system. Then you need to make sure the function documentation actually provides that information, in a consistent and readable manner.
It's a skill you have to practice, and it requires as much creative writing skills as it requires coding skills. Not all (or even most) programmers are that great at creative writing.
Admin
Its pretty scary a single function could do all that.
Admin
I was a comp sci major. I hate to say it, but I had a professor who wanted us to write comments about as verbose as this one. He was uniformly detested by his students, and he was terrible at grading work promptly.
In fact - the first of five assignments I turned in to him for my Data Structures class was returned to me on the last day of class, after the fifth assignment had been turned in as well. I'd had numerous points deducted because my comments... well, because they didn't look like this.
Of course, they still don't, so. Nyah.
Admin
...err...um ...that '-13'??? Would that be in hexadecimal?
Admin
Back in my day, CompSci majors/graduates didn't write programs. They wrote definitions for lexical parsing systems that were impractical, obtuse, and yet impressive. The stereotype is CompSci majors vs. world-weary programmers who have to try and implement such faerie castles, much like the stereotype of Electrical Engineers vs world-weary electronic technicians who have to hammer all of the bugs out of the design because the real world was never actually taken into account by the design engineers.
There, is there anybody left I've failed to irritate? I was born a couple years too late to qualify to be an "undegreed engineer", so even though I've been in the business for 30+ years and know computers from the electron hole theory of silicon solid-state semicondutors through operating system implementation and on through database design and user interfaces (by doing it), I never got a degree and harbor a natural skepticism of people who seem unduly proud of theirs. To me, PhD stands for "Piled higher and Deeper".
Back in my day, hard drives were the size of pizzas and held 5 megabytes.
Admin
Comments are for the programmer that has to maintain your application six months from now. That poor soul will probably be you.
I don't think comments alone really cut it. I often need screen captures to help me find things. I create help collections for my major projects and then integrate them into the MSDN Library. I also print out my database schema so I don't need to fire up SQL Server just to get a column name.
You can create Class Diagrams using UML in Visual Studio but I don't use that often enough. Tracepoints have proven to be quite useful to me when a stack trace can't be used to document the method calls during execution. You should also instrument your code with trace listeners.
I won't even mention the videos.
Admin
Genius! Why don't you dig out the code and open-source it?
Admin
It's The Adams Rule of Work-Related Horror Stories: any story about one or more horrible coworker who have a horrifying habit of doing non-criminal act X can be retold with a change in narration as a story about one or more horrible coworkers who have a horrifying habit of neglecting to do X, and both stories will seem perfectly reasonable as long as they are not directly juxtaposed. This rule is named after Scott Adams not because he discovered it -- he may or may not even be aware of it -- but because a close reading of Dilbert cartoon strips reveals that he has told the same story from both sides several times.
Admin
This is like the documentation-equivalent of computer-generated code. If someone wrote a compiler that could actually generate documentation for a function by looking at its code, this is what it would look like.
Admin
There fixed that for you. Us old timers that have been doing this for years for some reason seem to be ex musicians. I have always been able to put together impromptu jam sessions simply from the rest of the team around me. Now that shows we have the creativity.
Admin
Admin
I've seen the code and I don't quite understand it. Can you add some comments?
Admin
Yep, I started reading the comment block and started thinking this looked like a list out of a requirements document or a DOORS database or some such, and the programmer was perhaps keeping the comments verbatim for requirements tracability.
This is what I deal with, working in the defense contracting industry.
Admin
Actually, the writing style reminds me more of some electrical engineers I've worked with than CS majors.
Admin
I'll drink to that.
Admin
Is that documentation, or an actual COBOL program?
Admin
Can anyone think of a snobbier way of saying "Input must be correct", "No error handling here" or "Don't pass bullshit!"?
CAPTCHA: waffles. Yum!
Admin
Admin
What i like most about this post,
the authore seemed to have tried to emulate block text with his texteditor. but id didn't quitet work out as it should had;)
Admin
Admin
"sure, let me just..." universe implodes
Admin
(Sorry, I accidently hit 'reply' instead of 'quote')
"sure, let me just apply my..." universe implodesAdmin
No, -13 is just his way of saying "Hey, I don't know that unsigned data types can't take negative values!"
Chars can take negative values. Bytes are, by definition, unsigned, so the doofus is obviously not playing with a full deck on this one.
Admin
Nightmare.
Admin
Now the software engineers should learn from this guy on how to write comments!
WTF!
Admin
Quite welcome. Glad someone enjoyed it.
Admin
Another Knuth knut - see the example in Appendix A. And note the title at the top of page 12.
Addendum (2007-11-29 07:30): And this.
Admin
Since when do chars take negative values? What character is -1?
Admin
Admin
There are signed chars and there are unsigned chars. Signed chars can take negative values, although I'm not sure why one would want to.
The plain char is either a signed char or an unsigned char, but which one it is depends on your implementation.
Admin
Admin
Admin
I guess I have to dispute the latter part of that statement.
Many years ago, I worked with a guy who did an assembly language program to help test a realtime system. He did not put a single comment in the code and our boss dinged him big time, since the code was not maintainable. So he wrote comments on EACH line of the code, with statements like
LDA A W[1234] LSH L 1
becoming
LDA A W[1234] ; Load accumulator with contents of 1234 LSH L 1 ; Shift acc left by one bit.
This guy ended up at a mental hospital and I was the unfortunate recipient of all his work.
Admin
Admin
He! I also hate comments, instead I insert a .bmp file with a flowchart.
Bathe... no I won't... too many BMP's to convert to ASCII!
Admin
One wonders what your degree is in.... Having a BSCS for Purdue and having written a few million lines of code in the last 20 years, I would be happy to compare abilities....
Admin
What irks me is the apparent misuse of "id est". I'm very sure that what the author of this pretentiously moronic documentation comment was looking for is "exampla grata".
Admin
There's also just plain 'char', a distinct type.
BTW: I don't know what the problem is with the comment this article is about. Too much comment is better than no comment at all...isn't it? No-one's forcing you to read it, but it's there if you want to.
Admin
Other WTF is that he could have used a Multi-line comment, but instead he used 17 single line comments
Admin
I was thinking the same thing, actually. The oddball space in the word "external" really points it out to be a c'n'p.
Admin
At one point the other awkward boilerplate phrases ("The function operates on the presumption that these parameters are valid.") were probably on their own line(s) too, but over time they must have been re-flowed within the paragraph.
Exhibit A: not counting //'s, the number of characters in the "Description:" line (73) is exactly equal to the number of characters in the "presumption" sentence.
Actually I'm not sure the "external" spacing was part of the original; Alex may have introduced it. But I can't say for certain either way. Whatever, it's funny. :^)
Admin
...better than no documentation.
On my last job I took over a project (C++) which had been jointly developed with another company and in which my company had just bought out all rights. When the source code was delivered it did not have one comment anywhere (50,000 line of code). I assume that out of badness they passed it through some utility to strip out all comments. Sorry, there was one comment left in each file, the name of the original programmer at the top. Not only was it missing all the comments, it was so badly written I was surprised he put his name to it. A big rewrite was in order. In two days I managed to get rid of 10,000 lines of code. By the end of the second week I had halved the number of lines of code and lopped a third of the final binary.
Admin
Admin
well that clearly indicates that the function is a authenticator of the validity of the symbology modifiers being presented. The -13 would indicate that a previous -12,-11,-10... were already allocated to other functions as fail indicators forcing this functions need to be unique as a -13. Most likely the calling of the function would try for a positive number of zero and use the -13 number to look up the appropriate message to display back to the source of input which started the entire process in the first place. This is a very good way to document black box programs.
Admin
It is not that much of a joke. The words actually make sense in some context, for example in an implementation of the C standard library: As far as I know, most language specifications simply define the behaviour of functions, so that a C function itself is an "oracle", eg, you call Sqrt(10000) and it returns 100, but the specifications do not tell1 you how Sqrt(x) is actually implemented (my choice would be result=exp(log(x)/2), but it could also be iterated guessing or any number of ways I have not thought of, as long as it has the specified performance).
Admin
Error 523 origin is unreachable
Admin
It used some code from OTBSAF but was not itself OTBSAF, so there may be some cross pollination and overlap in staffing and coding idioms. Please pardon the thread necromancy, I just now noticed your comment from 17 years ago, haha.