Topic awaiting preservation: Commenting Code (Page 1 of 1) |
|
---|---|
Nervous Wreck (II) Inmate From: Juneau, Alaska |
posted 07-14-2004 20:17
Being a newbie to coding in general, I thought it best to cover this before I develop bad habits. I need to know approriate general commenting etiquette. When coding, what should I comment? Every little line is obviously repetetive, but I don't want to leave things out. How do you comment? |
Maniac (V) Inmate From: Den Haag: The Royal Residence |
posted 07-14-2004 20:38
Everything what's hard to understand for you would be a good start. In the beginning this willmean you comment every little line. But over time you don't need so many many comments. If you try something experimental comments will be usefull too. The code and it's comments should be readable and understandable if you did not look into it over a year. You can alway strip out the comments when it's compiling time if you want too... |
Paranoid (IV) Mad Scientist with Finglongers From: Germany |
posted 07-14-2004 20:42
comments per se aren't bad, but they have to be in sync with the actual code... |
Bipolar (III) Inmate From: |
posted 07-14-2004 20:52
Comments as the code goes along (line-by-line/block-by-block) are good. They help explain what's going on, especially in the context of the rest of the system. |
Paranoid (IV) Mad Scientist with Finglongers From: Germany |
posted 07-14-2004 21:01
quote:
|
Bipolar (III) Inmate From: |
posted 07-14-2004 21:43
TP, I do not disagree with you. Not one bit. |
Paranoid (IV) Inmate From: France |
posted 07-14-2004 23:08
For me, there's two types of comments :
|
Maniac (V) Inmate From: Boston, MA, USA |
posted 07-14-2004 23:25
"Maybe give the next guy some inspiration." |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 07-15-2004 00:44
Just from usage I tend to comment using the javadoc format. Usually all functions are declared with the input, output and use. Within functions, if there is something tricky or a some kludgey hack I'll comment that with the thought process behind it. Sometimes for wierd reasons you need to do something "wrong" to get the right results for reasons that are not self evident. These I always comments. I do pretty much the same things for objects explaining input constructors etc as well as the parent class. |
Maniac (V) Mad Scientist From: Somewhere over the rainbow |
posted 07-15-2004 00:48
The poster has demanded we remove all his contributions, less he takes legal action. |
Paranoid (IV) Inmate From: France |
posted 07-15-2004 01:23
quote: quote: In the project I've worked on, each developer was responsible of HIS code and was supposed to be the single person to update it and keep a sort of log in the comments at the top of his files. However, all the developers of the team had an overview of all the gears of the complete project and knew whom to ask for details on a specific area. When I finish a class or a feature, I generally provide an example with it so that the other devs don't even need to open the source of the classes to know how to use them. |