Hm, yeah, that doesn't even count. It's all throw-away stuff.
Anyone that thinks "comments" are optional, Is optional. But
it's your mess so what I think doesn't matter.
You miss understood my statement! I did not intend to imply that comments
are optional. I actually meant that a lot of comments are redundant. If you
label (name) the code for what it does, then I (in addition to Fowler &
Kerievsky below) don't see a real need for the comment. Fowler also suggests
that if you have a block of code with a comment preceding it, that you
should move the block of code to its own method, with the comment as the
name of the method.
Another example is putting a comment on a variable or parameter declaration.
If you simply pick a fuller name for the variable or parameter, do you
really need a comment on it?
For example, I have a routine that needs two date variables:
' with comments
Dim d1 As DateTime ' the start date
Dim d2 As DateTime ' the ending date
' without comments
Dim theStartDate As DateTime
Dim theEndingDate As DateTime
If you simply name the first variable as theStartDate do you really need a
comment suggesting the value is the start date?
Consider seeing d1 & d2 used 5 times in your routine, would the code be as
readable as using theStartDate & theEndingDate?
Would you need comments when you use d1 & d2?
Would you need comments when you use theStartDate & theEndingDate?
In other words "Human-Readable Code" or as Fowler states in Refactoring "Any
fool can write code that a computer can understand. Good programmers write
code that humans can understand".
You may want to read (& apply the ideas in) Martin Fowler's book
"Refactoring" and Joshua Kerievsky's book "Refactoring to Patterns" both
from Addison Wesley to have a better understanding of my statement.
Hope this helps
Jay
Mr X.
comments. Code without comments is rather worthless.
JH [Mon, 13 Sep 2004 15:30:37 -0500]:
In my experience well written code shouldn't need comments!
Well, see, that's in your experience, which obviously has never
had to deal with SOMEONE ELSE's "well-written code" (haha).
' adopted to VB.NET
Public Shared Sub Main()
Hm, yeah, that doesn't even count. It's all throw-away stuff.
Anyone that thinks "comments" are optional, Is optional. But
it's your mess so what I think doesn't matter.
--
40th Floor - Software @
http://40th.com/
iPlay : the ultimate audio player for iPAQs
mp3, ogg, mp4, m4a, aac, wav, and then some
w/surround, xfeed, reverb - all on your ppc