Originally posted by: Descartes
Originally posted by: gopunk
Originally posted by: Skoorb
Originally posted by: BoberFett
If you don't document your code and I ever have to work on it, I will hunt you down and kill you.
Documentation is extremely important in a large development project, or even in a small one that somebody else will have to maintain.
Documentation = bad job security. If nobody else can read it they need you when it breaks! I hate documentation, and in terms of commenting...well I just don't do it unless what I'm doing is a very complex function or it seems very weird, so I may give a few lines in case somebody is reading it so that they can see why the hell I did it that way. Otherwise, no comments for you!
and what happens when they give you code that you wrote 2 years ago and ask you to fix it? at the very least, save a documented version for yourself, if you're worried about job security. it's simply shoddy workmanship not to comment your code.
I've always disagreed with the "always comment" mentality quite simply because they are almost always misused:
- The comments are either way too granular or too coarse; never seems to be an acceptable middle ground. e.g.:
// Calculates tax total, transacts a deposit, does a bunch of other things that should be refactored into their own functions, etc.
void SomeFunction()
// Add tax total
runningTotal += taxTotal;
Contrived examples, yes, but they happen all the time in the wild. The point is that comments are often used to supplement the fact that the code isn't readable, and that naming conventions were not used. If SomeFunction() were properly refactored using lucid names, no comments as to its function would be needed. The second comment was entirely superfluous, and the abstraction was not that much higher than the actual code itself. I just want to see the code.
- The comments are decoupled from the code and thus do not reflect what the code actually does. People often change code and not the comments, so what you're left with are invalid comments. A single invalid comment makes me distrust any other, so it renders them completely useless at this point. This is ameliorated slightly by the inclusion of comment facilities in the language itself (e.g. JavaDoc, C# XML Comments, other preprocessors for C or C++, etc.). To maintain comments AND code means you have two changes for every one; this violates basic development principles such as DRY and OAOO.
Ok, I'm typing too much, so those should be enough. I'm not at all against documentation; however, I am against using them to supplement an inherent problem in the codebase. I am also against them when they are superfluously used, as heavy commenting makes code much harder to read. It's my opinion that quality code is MUCH easier to read than trying to understand what the programmer is saying (code is unambiguous, the semantic value of language is entirely ambiguous).
IMO.