Advertisement

An objective analysis of comments: Are they necessary?

Started by November 03, 2000 09:53 PM
83 comments, last by The1Blade 24 years, 2 months ago
I am of course just an evil anonymous poster, but.......

I think comments are making the code less readable and they make it look ugly!
I have an easier time reading the code cuz it has no typos and such things in it(you know you''ll get compiler errors when your syntax has typos).
I don''t like other people browsing thru my code they are just supposed to be users and look at at the interface(accessor funcs etc) they couldn''t understand it anyways
I think using 3rd party stuff isn''t good anyways it''s commercial everything that''s thought to be sold sometimes has to fit into schedules and so it''s released earlier cuz people do not only pay money no they also can do the debugging.
if it wouldn''t be commercial it''d be 99.9% bug free
if I would need to change major parts of it well what would be the point in using it then anyways??

Hmm writing a li''l prog that deletes the comments out of the code might be a usefull tool and for comment fetishes why not write program that let''s you look at your code in html style or something you could browse thru your comments && search for further information about the comment related topics and son on of course you''d have to use a scripting like comment style and you could put it on the net directly and everyone could read it maybe u could even sell it to others as reference to my main render loop and novel of the ai algorithm - Why those pesky little rats are more intelligent as npc''s in other games
Cheers
If you ever hope to hold a real professional programming position of any kind you damn well better use comments.

If you don''t see why they''re useful, you''ve obviously never done anything above the complete tinker-toy level of beginning programming.

As for the whole "rewrite the module" argument - that''s completely stupid. What if the module is 15,000 lines of code and you have 2 days to fix a series of bugs. No way.

Or suppose, you''re handed a pre-compiled library (common at many large development houses) and a header file with no comments? Hmm, can''t exactly rewrite the library now, can we?

You''re kidding yourself if

a.) You think that you''re so good you have no need to comment. When you get into the professional world you''re going to find that pretty much everyone is as smart or smarter than you. And they comment. You lose.

b.) You think there''s no need to comment stuff because you can always re-write it. Real world time constraints make this a complete fallacy.

Do yourself a favor, ignore anyone who says comments aren''t worth it.
Volition, Inc.
Advertisement
quote:

I disagree. First of all, most errors are syntax errors, which you can easily and quickly fix without complex. About logical errors, after you finished your code, it''s still all fresh in your mind. And you wouldn''t simply make a huge thing that took days and only compile it then. No, you compile modules separately, and test them from the main program. They are still fresh in your mind, so you still know exactly what you did in there.



This is ludicrous, and you''re making yourself sound very dumb. In the "real" world, if you''re checking in code that doesn''t even compile because it has syntax errors you''d be fired in a week. The _vast_ majority of bugs in code are no syntax errors.

Proper commenting allows another competent programmer to go in and fix someone else''s code. If you''re 3 days away from a drop-dead ship date, you can''t just go in and re-write major portions of code. And if you have to fix some serious bugs in a major module with no commenting, you may as well be doing surgery with a chainsaw. There''s a super-high chance that all you''ll do is introduce more bugs and further screw your release.

I _dare_ you to go into an interview for a programming position and tell your interviewers that you think commenting is basically pointless. They''d laugh so hard and your interview will be over so fast it''ll make your head spin.

Sure, work on toy projects and don''t use comments. That''s a brilliant way to prepare for the future when you''re doing something of any significance.
Volition, Inc.
quote:
Vetinari
1: You would be hard pressed to find code with the amount of text equalling the amounts of comments. So less than double space.
The1Blade
It happens often, when you have complex code that deal with various different parts, in various different ways, this does happen if you comment.


Let''s see, most code I work with has one line of comments per ten lines of code, and mabye one per three if it is extremly complex. I would like to know how you came to the conclusion that this happens ''often''.
Of course I put more weight into good variable/function names, but many times that alone is not sufficient and the code needs more.

quote:
Vetinari 2: Comments don''t require as much thought or planning as the code, therefore it should not take as much time if you comment a line after you have written it.
The1Blade
I disagree. Code is less characters first of all. And the logic behind it doesn''t matter. When you make a string of code, you KNOW EXACTLY what you need to know, you know exactly what you want to right in a certain loop, if statement, or even a large algorithm. You wouldn''t just start something and write capriciously from there.

You would be hard pressed to find many here that agree that the nuumber of charecters in comments is greater than thta of code. And if this happens, you may be over commenting. Of course if people write comments like ''want to right in a certian loop'', the reader will get confused.

quote:
Vetinari 3: Comments don''t require debugging, which most will say takes more time than actually writting the original code. So now we see percentage of time writting comments decrease significantly. Not to mention that studies show that comments in large products significantly decrease debugging/maintenance stages (see code complete). For me, commentang doesn''t even take %10 of my time, and probably saves considerably more than that.
The1Blade
I disagree. First of all, most errors are syntax errors, which you can easily and quickly fix without complex.


Are you on drugs? Exactly what part of what I said do you disagree with? I rarely get syntaxical errors, and generally finding bugs takes incredibly longer than writting the original code. Most large products go through multiple month long debugging processes, where new features are not added. I wonder why they don''t go through month long syntaxical fixing periods?

It''s pretty obvious you have no real world experiance. When you get some, come back and we can discuss this further.

Mike
"Unintentional death of one civilian by the US is a tragedy; intentional slaughter of a million by Saddam - a statistic." - Unknown
daveb yes you are so right at least from the commercial programmers point of view, but commercial programmers can''t be good programmers anyway since all they see is money and time schedules, and all they create is bugs and bugs if you would be programming for the joy of it you''d probably hate comments in your code(.c/.cpp) files a few headers might need comments but only a few (mostly belonging to dlls and libs).
The value of comments is inversely proportional to the experience of the programmer relative to the program being worked on and not the other way around. Do you really need a well commented "Hello World" program to understand? Perhaps you do, but my guess is no. Was that always true? I''ve been programming for about 20 years. Your experiences may vary, but I generally find what was complex to me five years ago isn''t today. Personally I find I get more experienced instead of the other way around, but that is because I keep programming. As you gain experience you learn to recognize patterns faster. If you have never done a quicksort then perhaps you won''t recognize one, but if you are an instructor reviewing a hundred of them a semester I doubt comments do anything except explain what the student didn''t understand and why they got it wrong. As a student you might well forget because you don''t have any use for it for several years because you use a utility or function instead. Under those circumstances I''m going to go to a book that explains a quicksort rather than looking at old code and the comments it contains even if I have to change the old code.

I find comments that only inexperience programmers don''t value comments to be offensive. I certainly appreciate explainations of how to do things I don''t know how to do, but I turn to a book for that, not source code. If I''m working with others then I would much prefer a seperate document with little things like block, state transition, entity relationship and data flow diagrams to understand it. The idea that the best way to understand a large complex application is to read all the comments seems at best naive to me. Personally I would like people to be perfectly honest here. How many arguing the merits of comments actually write any documentation for their programs? If you don''t then I must insist that it would be a better use of that 10% of your time to write the frigging documentation.

As for what I''m going to do one someone elses dime is a differant story. I''m either going to do what is demanded of me or decline the job. This wasn''t a question of what is demanded of you on your job. What was demanded of me the last year of my job was to set on my ass doing nothing while they debated for three months whether the cost was worth the benefit of me working for a week to cut a $100,000 from the annual cost of running the system. I have to question if anyone arguing the "professional" world is this happy, perfect place has any real experience. The "professional" world is full of people that cannot program, managed by people that have no idea what it takes to write a program much less the differance between a good program and a bad one. Comments is a simplistic concept they can grasp. Oh, comments is good so anyone that doesn''t comment is bad and anyone that does is good. Duh, the quality of a program is the quality of the code and not the comments. Comments are a nice to have if you have to work on a program beyond your skill level and the best comments in the world does not make up for a lack of program documentation.
Keys to success: Ability, ambition and opportunity.
Advertisement
that was a good post especially the last line: comments are ...
that reminded me sometimes i comment stuff for fun if i know someone else will read the source i put jokes in there for those people (i know who gets to read my code if anyone) that makes the code nice to read... heh we even decided to make something like a story out of those comments they should tell about stuff happening outside of the computer things like black holes suddenly appearing or your mouse getting eaten by a cat or maybe just a friend of yours bringing you a ''warez'' version of the game you just started programming!
Um, an *objective* view is not what you presented here. An objective view is when you argue for both sides. Your view is strictly subjective.

Also, you only argued that co-workers should know and it wont help yourself. However, no one reads code as good as English, besides the claims. Its impossible, because I can read badly formatted and to a certain extent misspelled English, but I severly doubt anyone can do the same with code. Pick any random .c file at www.ioccc.org and if you can read it like English, you deserve a quick slap in the face, for lying.

Now, perhaps your style is good, and you plan never to change it. Comments are not to state obvious stuff. If you write, for example,

i++; // Add 1 to i

then you are right, comments are useless. But, as I said, comments are not there to state the obvious. They are there because of so many possible pecualuralities in any given peice of code, it becomes hard to maintain.

(Being a taste of your own medicine)As for people who comment and comment over there comments, et etc. Well, I have the same argument you have been giving me about badly written code: No one should do that(End a taste of your own medicine)

-----------------------------

A wise man once said "A person with half a clue is more dangerous than a person with or without one."

The Micro$haft BSOD T-Shirt
-----------------------------A wise man once said "A person with half a clue is more dangerous than a person with or without one."The Micro$haft BSOD T-Shirt
quote:
Original post by LilBudyWizer
I find comments that only inexperience programmers don''t value comments to be offensive.


If that''s directed at me...I think you misunderstood me. I never generalized to all, I was attacking his experiance becuase honestly I don''t find hist arguements well formed.

quote:

I have to question if anyone arguing the "professional" world is this happy, perfect place has any real experience. The "professional" world is full of people that cannot program, managed by people that have no idea what it takes to write a program much less the differance between a good program and a bad one. Comments is a simplistic concept they can grasp. Oh, comments is good so anyone that doesn''t comment is bad and anyone that does is good. Duh, the quality of a program is the quality of the code and not the comments. Comments are a nice to have if you have to work on a program beyond your skill level and the best comments in the world does not make up for a lack of program documentation.

Honestly, I have no idea what kind of experiance you have in the professional world, but I had no experiances like that. In both jobs, the higher ups either had programming experiance or let programmers make all programming decisions. Both demended of me moderate documentation of my code (comments). If you had a different experiance, that''s fine, I was just sharing mine.


Mike
"Unintentional death of one civilian by the US is a tragedy; intentional slaughter of a million by Saddam - a statistic." - Unknown
Heh. I''d wager this guy doesn''t have 20 years of experience. In fact, my rough estimate would be about, oh, zero.

Any supposedly "experienced" programmer who is arguing against the value of comments in his code is equivalent to a experienced soldier who is arguing against the value of bullets in his gun.

Its stupid. Do engineers layout car parts with just pictures, and leave out the dimensions and descriptions? No. There would be no cars.

Eh, this argumnent is inane. If you''re an "undecided" programmer reading this, take it to heart - you''ll never make it as a professional programmer if you don''t believe in comments.
Volition, Inc.

This topic is closed to new replies.

Advertisement