quote:Original post by felisandria
I think Xai misunderstood me somewhat... I do not condone commenting to an extreme. I would never put:
int index; // this is an integer that holds the current array index
It helps to think of this in terms of giving someone directions to get to your house. Comments just make it a little easier to help you get there. For instance:
Turn left on Inverness.
Turn right on I-25.
Turn left on 6th Avenue.
Turn right on Simms.
Turn right on Oak.
Go to house #423.
(No, these are not real instructions to my house.)
While these instructions (code if you will) will indeed get you to where you''re going, it''s a lot more difficult than this:
Turn left on Inverness.
// Get in the right lane, I-25 is in 2 blocks.
Turn right on I25.
// Drive about 6 miles. Look for the 6th Avenue off-ramp.
Turn left on 6th avenue.
// Drive about 5 miles. Look for a big Oak Express furniture store on your right before the exit.
Turn right on Sims.
// Oak is the first right turn after the exit.
Turn right on Oak.
// It''s a big blue house with white trim.
Go to house #423.
Tell me, which directions would you prefer? I could have over-commented, telling them to pass a white house and a green house and a red house and an empty lot, and telling them every single store and billboard on the way... but the point of comments is to give people just a little bit more direction. Comments put code in perspective, give you insight into the goal of that code, and help with functions that might seem ambiguous (and even if everyone at your company is a code god and makes beautiful function names, you WILL, at some point in your life, be forced to use a third-party library or API that does not.
Got comments?
-fel
YES! YES! YES!
I agree with you totally. I don''t do a lot of C/C++ yet, but am learning and some of the source code I''ve seen on the net is HORRIBLE to look through. Comments are the only things that keep me going on it sometimes, but when there are no comments, I chuck it down and see if I can find it somewhere else or in a book.
I''m mainly a VB programmer and even there you have to use comments. Even though some of you look down on VB, it is pretty powerful for the stuff it does do (DB, Internet, etc..) and it can get just as cluttered as C/C++ does.
BeS
It's Da BOMB Baby!!!