do you comment?

Started by
209 comments, last by Gaiiden 19 years, 10 months ago
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!!!
BeSIt's Da BOMB Baby!!!. o O ~ A little nonsense now and then,is relished by the wisest men~ O o .-- Willy Wonka
Advertisement
quote:Original post by Davaris
...
Dark Lozar

I’d tear strips of you if you coded like that working for me. You’ve got more comments than code man! How do you get anything done?
...

Davaris,
Some people can actually type fast... I can assure you that I 1)Write more lines of code in a day than most of my peers and 2)That it is commented well enough for the maintainer that follows me can figure out what I''m doing.

Therefore, I think it safe to say that I wouldn''t ever work for you corollary, you would never work for me

Comments are necessary...


Dave "Dak Lozar" Loeser

Dave Dak Lozar Loeser
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."--anonymous
The only commenting I require (and desire) of my programmers is at the function / method level. If you cannot articulate what is happening in the function / method then it is too long or the programmer does not fully understand the problem. On some level it comes down to your environment. If you work with a team, or plan on using you codebase for multiple projects, then "good" commenting can save weeks of manhours. However even with "good" commenting an existing codebase things WILL eventually go awry. Five other lazy programmers will add hacks to without trying to understand what it was doing in the first place, leaving the existing comments and hosing things up for the next guy(note to self: fire the five lazy programmers).

But hey it''s only an opinion, if you don''t work for me then why should you care what I think? (do what works / learn from experience)

Pest
"-- Good judgement comes with experience. -- Experience comes with bad judgement."
quote:Original post by Pest

(note to self: fire the five lazy programmers).


Hey, can I come work for you then? I''m a non-lazy VB programmer if you need one.



BeS
It's Da BOMB Baby!!!
BeSIt's Da BOMB Baby!!!. o O ~ A little nonsense now and then,is relished by the wisest men~ O o .-- Willy Wonka
You would not want to work here... We write mine and geological modeling software. I''ve written entirely too many cad tools, surface intersectors, contouring engines, mesh generators etc.... We squeezes all the fun out of graphics programming. I have to write games on the side to remind myself that graphics programming can be fun. Man I need a different job...

Pest
quote:Original post by Pest

You would not want to work here... We write mine and geological modeling software. I''ve written entirely too many cad tools, surface intersectors, contouring engines, mesh generators etc.... We squeezes all the fun out of graphics programming. I have to write games on the side to remind myself that graphics programming can be fun. Man I need a different job...

Pest


As long as it makes more than 18,000/yr. and has some decent benefits I wouldn''t mind it for a year or so.



BeS
It's Da BOMB Baby!!!
BeSIt's Da BOMB Baby!!!. o O ~ A little nonsense now and then,is relished by the wisest men~ O o .-- Willy Wonka
Wow, milo sure posted a great example of why to comment. I believe that would have led me to kill whoever that was if he hadn''t commented it. And speaking of such, it''s quite ironic that after I put up this post, two people in my company up and quit. They had been working on a program and sent it to us before they left. Guess what? That''s right... NOT A SINGLE FRIKIN LINE OF COMMENTING IN THE WHOLE DAMN THING!!! fortunatly its only 14 (ha ha!!) pages (when printed in landscape format), but me and my buddy have to go through it bit by bit and figure out what the hell everything does. Some of this stuff we''vew never even seen before! Anyone know what the hell #pragma (used like #define) means?? If so, look for my thread in the General Programming section and tell me, cause I''d really like to know - ya know? I''m about ready to track them down and return with their severed heads as a message that all programmers should comment.... okay maybe that''s a bit too much..... naaawww...

==============================
\\// live long and prosper; \||/ die short and rot.
==============================

Drew Sikora
Executive Producer
GameDev.net

#pragma is a compiler instruction. For instance,

#pragma once

is basically the same thing, to your compiler, as

#ifndef
_THIS_HEADER_
#define _THIS_HEADER_

... code ...

#endif
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
comments are for wimps.

Well, I guess if you''re on a project with multiple people, you can comment the really nasty algorythms.

But in general, COMMENTS ARE FOR P___I_S!

hanks, felisandria, I have VC++ 4, so it may be out of date... dunno why it wasn''t in the help index. And as for Buster, I hope he realizes the truth of his post so I can laugh at him I''m done, see ya all tomorrow....

==============================
\\// live long and prosper; \||/ die short and rot.
==============================

Drew Sikora
Executive Producer
GameDev.net

This topic is closed to new replies.

Advertisement