Remember: Always Document Your Code

NiteWulf

Golden Member
Jan 3, 2003
1,112
1
0
And remember to write clear, definite, discernable comments:

Part present doesn't seem to make when collet is down empty, but it might.




Share your code comments.
 
Last edited:

Exterous

Super Moderator
Jun 20, 2006
20,481
3,601
126
So thats where I put my note. Thanks for finding it - now I can fix that bug thats been bothering me
 

skimple

Golden Member
Feb 4, 2005
1,283
3
81
Nertz to you! Figure it out for yourself.

That's how I learned!

Damn kids and your "comment yer code". Whiners! The lot of ya!
 

rh71

No Lifer
Aug 28, 2001
52,844
1,049
126
I don't have the best memory and I don't feel like reading through the entire code to see what I'm doing... commenting in detail is the best thing I can do for myself. Sometimes it's 2+ lines.

ie. just for one snippet
<!---
SET VALIDATED TO RECEIVED BECAUSE THESE CAME IN FROM IMPORT TABLE (NON VALIDATED after period) AND SHOULD BE RE-VALIDATED, RESET EMAIL SEND DATES.
THOSE STILL IN RECEIVED ARE PASSED-THRU WITH NO PROCESSING UNTIL SEND-OUT.
THOSE ACTUALLY VALIDATED NOW WILL BE SET VALIDATED FURTHER BELOW.
--->

Good thing too because they asked me to change the app up after 2 years not touching it.

Also have change logs with dates at the top of the code, also thanks to my memory.

Anyone else also use a ton of line breaks to separate sections of code so you can actually read / understand it better?
 
Last edited:

Train

Lifer
Jun 22, 2000
13,572
66
91
www.bing.com
I don't have the best memory and I don't feel like reading through the entire code to see what I'm doing... commenting in detail is the best thing I can do for myself. Sometimes it's 2+ lines.

The only problem with a lot of comments is that they tend to get stale over time. Code changes, and comments are left alone. Even unintentionally.

While I don't advocate removing comments altogether, I do encourage more use of the comments on the SCM check in to keep specific versions of code with the relevant comments.

Side Note: was reading about the linux kernal, Torvalds says to commit changes to the kernal, you ned 50-70 lines of comments (in the commit message) PER LINE of code changed.
 

Alienwho

Diamond Member
Apr 22, 2001
6,766
0
76
If you're working with a team of other developers and you all will be using the code then you're just a dick if you don't comment. If you're a lone wolf and the Company you work for might screw you over you could be guaranteeing yourself many thousands of dollars in post-employment consulting fee's by not commenting.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
Most of the comments I come across look like

//this is fucked

//i didn't write the following lines of code, don't blame me

///@@TODO
 

insect9

Senior member
Jun 19, 2004
954
0
76
If you're working with a team of other developers and you all will be using the code then you're just a dick if you don't comment. If you're a lone wolf and the Company you work for might screw you over you could be guaranteeing yourself many thousands of dollars in post-employment consulting fee's by not commenting.

Job security through obscurity?
 

Train

Lifer
Jun 22, 2000
13,572
66
91
www.bing.com
If you're working with a team of other developers and you all will be using the code then you're just a dick if you don't comment. If you're a lone wolf and the Company you work for might screw you over you could be guaranteeing yourself many thousands of dollars in post-employment consulting fee's by not commenting.

I've heard there are actually tools out there that will strip out all comments for you before you check in, but leave them in local files.

I can really only think of one use for such a tool.
 

Possessed Freak

Diamond Member
Nov 4, 1999
6,045
1
0
Comments I have used recently:

//don't modify the following, I am initializing variables so the program does not crash
//counter
//another counter
//had to subtract 1 from the variable so the program would end properly
//Yes I am just reversing the positions in the array, makes the math easier.
 

Red Squirrel

No Lifer
May 24, 2003
68,473
12,618
126
www.anyf.ca
Actual code in one of my applications that has never been released to public:


Code:
//Decide what post action we want to do (new topic, reply, edit post, etc)
//This is one of the most horribly coded sections and will probably give you nightmares.  Scroll down at your own risk.  
//One day I'd like to find a better way for this

Worse part is, back in that time I never bothered indenting my code. Too bad though as the app itself actually did work very well and it was almost ready to go through some vigorous testing then release but the code is terrible. I was just learning php. It got me an A as my tech report in college, so that's all that counts, I guess.
 

Possessed Freak

Diamond Member
Nov 4, 1999
6,045
1
0
Worse part is, back in that time I never bothered indenting my code. Too bad though as the app itself actually did work very well and it was almost ready to go through some vigorous testing then release but the code is terrible. I was just learning php. It got me an A as my tech report in college, so that's all that counts, I guess.

I indent all my code, I *refuse* to review other code that is not indented. Lack of comments is one thing, lack of indenting... NO.
 

Red Squirrel

No Lifer
May 24, 2003
68,473
12,618
126
www.anyf.ca
I indent all my code, I *refuse* to review other code that is not indented. Lack of comments is one thing, lack of indenting... NO.

Yeah, now I'm the same way. I look at this code and I can't believe how terrible it is. D: Really I'd have to go through, indent it, and see if I can optimize it. I put so much time into that project I'd have to actually pick it back up again and release it. Though it may be easier to practically rewrite it from scratch and just go pick out parts of code for some of the logic.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |