Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

View Poll Results: Do you comment your code?
All the time 17 29.31%
Sometimes 35 60.34%
Never 5 8.62%
Commenting? 1 1.72%
Voters: 58. You may not vote on this poll

Reply
 
Thread Tools Display Modes
Old Jun 3rd, 2006, 4:17 PM   #31
RobEasy
Programmer
 
RobEasy's Avatar
 
Join Date: May 2006
Location: The US duhhhhh!
Posts: 42
Rep Power: 0 RobEasy is on a distinguished road
I am still learning to code, so I use comments to go back and see how I used my code. That is the important thing to do for me. Although a simple design with explicit code does allow for transparency, I would still like to comment, especially if I come up with a large program.
RobEasy is offline   Reply With Quote
Old Jun 3rd, 2006, 6:35 PM   #32
Harakim
Hobbyist Programmer
 
Join Date: May 2006
Location: West Jordan, Utah, United States
Posts: 176
Rep Power: 3 Harakim is on a distinguished road
Also, I think commenting helps you write better code which ironically mitigates the need for comments.
Harakim is offline   Reply With Quote
Old Jun 3rd, 2006, 6:48 PM   #33
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Quote:
I think commenting helps you write better code which ironically mitigates the need for comments.
If commenting helps you write better code, then you didn't design your code first, which you should. Whether or not better code mitigates the need for comments is strictly circumstantial. Someone could write you some absolutely beautiful, efficient, and functional code. If you didn't know what was going on (encryption or nuclear physics, anyone?) you couldn't decipher it without an explanation.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jun 3rd, 2006, 7:16 PM   #34
Adak
Hobby Coder
 
Join Date: May 2006
Posts: 57
Rep Power: 0 Adak is an unknown quantity at this point
Had a couple experiences with "This can't be my code - it doesn't LOOK like my code! It doesn't even look like it was written by a HUMAN, at all!!".

I strive for more clarity in my programs, and definitely more comments, and more informative comments. Every non-trivial line of code will have something for a comment.

Adak
Adak is offline   Reply With Quote
Old Jun 3rd, 2006, 8:11 PM   #35
Mad_guy
Hobbyist Programmer
 
Mad_guy's Avatar
 
Join Date: Oct 2004
Location: Sandstorm, Techno Club
Posts: 239
Rep Power: 4 Mad_guy is on a distinguished road
Send a message via AIM to Mad_guy Send a message via MSN to Mad_guy
I comment things like my Data structures fairly well and my functions, inside a function I don't document as much myself.
__________________
os: mac os 10.5.4
revision control: git
editor: emacs

site
Mad_guy is offline   Reply With Quote
Old Jun 3rd, 2006, 10:16 PM   #36
chepfaust
Programmer
 
chepfaust's Avatar
 
Join Date: Feb 2005
Posts: 62
Rep Power: 4 chepfaust is on a distinguished road
Quote:
Originally Posted by Eric the Red
I comment everything!!!! line by line, even if it's wrong to do so.

This is mainly due to the fact that I have a horrible memory and so the comments help me remember what I'm doing.
line by line is a little excessive, but i'm with you in spirit.

perhaps it's a total noob thing to do, but i always start my programs by using comments to write out, in plain english, every step of everything i want my finished product to do. this is the extent of my commenting.

then i go and create my code in between the comments.

it not only helps when i need to go back and look at something i wrote six months ago, but while i'm in the process of coding it helps me maintain focus on what i need to accomplish.
chepfaust is offline   Reply With Quote
Old Jun 4th, 2006, 3:50 AM   #37
Mocker
Hobbyist Programmer
 
Mocker's Avatar
 
Join Date: Oct 2005
Location: Indiana
Posts: 218
Rep Power: 0 Mocker is an unknown quantity at this point
Send a message via AIM to Mocker
I dont' comment and I write a lot of confusing code. This way, I can open the same program a little later, and its like a whole new puzzle trying to figure it out, instead of boring "yea it does this" type code.
__________________
#programmingforums relay - http://thegupstudio.com/cgi-bin/pforelay.cgi
freelance scripts - http://ryanguthrie.com/index.html
Mocker is offline   Reply With Quote
Old Jun 4th, 2006, 6:40 AM   #38
rsnd
Hobbyist Programmer
 
rsnd's Avatar
 
Join Date: Jun 2005
Location: Helltown
Posts: 162
Rep Power: 4 rsnd is on a distinguished road
hmmmm...I start coding with comments
__________________
Spread your wings and fly! Chicken!
rsnd is offline   Reply With Quote
Old Jun 6th, 2006, 11:04 AM   #39
Griz803
Newbie
 
Join Date: Jul 2004
Location: Somewhere in them thar hills
Posts: 23
Rep Power: 0 Griz803 is on a distinguished road
I usually find that if I stick to three rules, it works pretty well. They are:
/*1) If it isn't clear enough to me at the time of the writing to explain in 3 line comments, I'd better look around some more because I'm being DUMB!
2) Make sure that all your variables, structures, classes and functions are explanatory in their own names and code.
3) Switch rule 1's and 2's priority and check it again, document anything that doesn't look right and let some one else read it to see if they understand it.
If I get by those the first time, a miracle has occurred ;-)*/
Griz803 is offline   Reply With Quote
Old Jun 6th, 2006, 11:23 AM   #40
King
Professional Programmer
 
King's Avatar
 
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 377
Rep Power: 0 King is an unknown quantity at this point
Quote:
Originally Posted by Eric the Red
I comment everything!!!! line by line, even if it's wrong to do so.

This is mainly due to the fact that I have a horrible memory and so the comments help me remember what I'm doing.
Line by line might be a little much. Maybe you should have a comment about what the function or chunk of code does, then let the code explain itself. And if for some reason a certain line of code isn't obvious of what you’re trying to do, then add another comment in.
__________________
I am Addicted to Linux!
King is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:41 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC