Advertisement

Code Comments

Started by May 01, 2001 05:18 PM
29 comments, last by Shannon Barber 23 years, 9 months ago
I''ve decided to reverse my previous assertion that you should fully comment your code. I now believe you should not comment at all. Why? Because no comments at all are much better, and waste less time, than comments that are wrong. ... Just needed to vent Magmai Kai Holmlor - The disgruntled & disillusioned
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
This is the most absurd thing I''ve ever heard. blah!
Joseph FernaldSoftware EngineerRed Storm Entertainment.------------------------The opinions expressed are that of the person postingand not that of Red Storm Entertainment.
Advertisement
lol
Dont avoid comments, just use them sparsly.

I mean comments like this

x = x+1; //Add one to x

isn''t just a waste of space they make the code even harder to read and even more important the reader might not notice the important comments like when you''re using some non standard thing or doing some hack.

Comments should be used to clarify algorithms and alert when you doing something strange, not to repeat the code in the comments.
Comments and other code docs are for SISSIES!

It''s also a good way to get yourself fired after the project is done. We can read your code, why do we need you?
Not commenting is a better way of getting yourself fired.

Epolevne
Advertisement
I rarely ever comment. It usually takes me longer to explain things in english than it does for me to make them work in C++ (well, not really, but still enough time to seriously slow down my progress), and since I''m not working with anybody else at the moment, I can do whatever I want^^



-Deku-chan

DK Art (my site, which has little programming-related stuff on it, but you should go anyway^_^)
I comment only when absolutly necessary. If people can''t understand what''s going on then they either don''t know the language well enough (or are too lazy to think for a second) or my code is sloppy.

I personally don''t need much commenting. I can read my code as plainly as english even years after not looking at it.

Ben
http://therabbithole.redback.inficad.com
Apparently some of you haven''t been to a code review. A good way to look bad in the eyes of your co-workers is to write something that they cant follow. If you are working on AI and nobody knows anything about AI, they wont know what the heck you are doing without comments (unless you have overly descriptive function names and variable names).

Besides, comments don''t have to be just one liners. Putting a paragraph in comments describing what you are going to do in the following block of code can be incredibly helpful for others and yourself if have to look at it a long time from now.

Even at home I add comments just to organize my code better. Whats easier to look at?

  int functionX(int a, int b){...}int functionY(int a, int b){...}OR//--------------------------------// functionX does ...//--------------------------------int functionX(int a,int b){...}  //end of functionX//--------------------------------// functionY does ...// returning 0 will ...//--------------------------------int functionY(int a,int b){...}  //end of functionY  


For me, the second approach cuts down on the time it takes to find what I want. Its just a good habit to get into.
Sometimes I leave comments out, because 1.) its funny that it pisses my lab partner off and 2.) then he doesn''t know where to start when he has some brilliant idea that I don''t want inserted in my code until he consults me.

But when commenting, I like to comment before functions (purpose and where the variables passed in should be coming from) and then only on wierd/hard to follow spots. And sometimes I throw in a comment for wierd loops/counters and stuff, just to avoid an off by 1 error if i make quick changes later without really looking at the code enough.



--OctDev
The Tyr project is here.

This topic is closed to new replies.

Advertisement