An objective analysis of comments: Are they necessary?

Started by
83 comments, last by The1Blade 23 years, 5 months ago
I think that comments are a necessary part of programming, just as footnotes are to authors. They are used to document what they have written when the intent or refrence may not be understood by the target audence.

To say that programmers should never need comments is like saying that authors should never need to use footnotes. Yes the footnotes are not NECESSARY for reading the document, but may give you insight into what the author intended.

Let me give one example that can hardly be cast away. You should always program clean code. What if there were a compiler bug, or a buggy library that FORCED you to program in a slightly backwards way. Without a comment to show intent the next programmer to come along and maintian your code will probably say why did they do that, and try to do it the "right" way and spend hours trying to track down the bug only to realize WHY you wrote your code the way you did. A simple comment would have saved this programmer fron frustration and waisted effort.

Advertisement
Yeah, I figured you''d say that.

Fine, using your definition, manipulation is necessary for success, at least definition 2.a. From context, it seems obvious that he was not using definition 2.a, but instead was implying at least detriment, if not dishonesty.

He talks about somehow manipulating the boss to be annoyed at your coworkers; I find that detrimental to all involved and implicating dishonest or, by your definition, insidious means.

If he says he was using manipulation in an helpful and honest manner, I will appoligize for the blatent miscommunication on my end.

As for objective, a well formed arguemnt examines both sides, only to (attempt to) argue against it. And I''m using Paul Cunningham''s definition of argment
ar+gu+ment n. A discussion in which reasons are put forward in support of and against a proposition, proposal, or case; debate.
What he made was obviously an argument and not an objective discussion. As far as I can tell, there is no such thing as an objective argument.

Alright, I think I''ve made a fool of myself enough for right now.



Mike
"Unintentional death of one civilian by the US is a tragedy; intentional slaughter of a million by Saddam - a statistic." - Unknown
quote:
Could it be that context is important? I, for one, need my documentation/comments in close proximity to the code. Whether that means liberal commenting in the code itself, or code snippets in the documentation, it helps me not to have to go back and forth.


I actually think this is quite insightful. It is one thing to see a good piece of documentation for an algorithm, but I find that well written (and therefore commented) code or pseudo code is almost essential for full understanding of the algorithm/implementation.

for the most part, the code should be self documenting, as umpteen people have already said, through use of sensible variable names and function names. But sometimes you might have to do something completely weird, for the sake of optimisation or whatever - a comment can reassure someone else looking at your code that you are doing what you intended to do, and that there wasnt a typo in your code. Commenting broadly what a block of code does and why it does it takes very little time to do, and it can save someone else hours of grief when he takes over your code. Steadfastly refusing to comment ''because it wastes time'' and ''any half decent coder should be able to figure it out'' is selfish and arrogant in my opinion. The amount of time and effort you put into ''manipulating'' your co-workers and explaining to them what a piece of code does almost certainly exceeds the effort required to put the comments in in the first place.
*lets out a gigantic yawn*

hehe... :D

I stopped reading in the middle of page 3 or somewhere...

daveb has made many many valid points. I could never see myself reading code (EFFICIENTLY) without comments.

Currently, I work for a product/consultant company. I''m coding a game in my off time. I have potentially thousands of people look at my code. Our code is modular. Our code uses good names for functions and variables that describe what they are (ie - to get a description of an MQ connection the function would be called GetMQConnectionInfo()....)

However, those thousands of people rely HEAVILY on comments in code. Are comments necessary? No. Probably not. But if you want maximum efficiency then you definitely need comments.

You may counter that a good user''s guide is preferred. I strongly disagree. Many coders have a very arrogant approach (much like what I see here...) towards reading a user''s manual or any documentation other than code. I get freaking support calls non-stop from people on the field who practically view reading documentation with disgust. You may think it''s the best way to go but you''re breaking standards. I''m sorry. It is often easier to break a twig then to bend it.

E.D.
Enoch DagorLead DeveloperDark Sky EntertainmentBeyond Protocol
As for objective, a well formed arguemnt examines both sides, only to (attempt to) argue against it. And I''m using Paul Cunningham''s definition of argment
ar+gu+ment n. A discussion in which reasons are put forward in support of and against a proposition, proposal, or case; debate.
What he made was obviously an argument and not an objective discussion. As far as I can tell, there is no such thing as an objective argument.

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

I said that about 2-3 pages ago.

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

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

This topic is closed to new replies.

Advertisement