![]() |
|
| 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 | |||
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Programmer
Join Date: May 2006
Posts: 85
Rep Power: 3
![]() |
Commenting your code
Commenting your code takes so much time and space, but it is a good practice and makes it so you dont lose what your looking for. And it makes it eaier to read.
__________________
Code Forums |
|
|
|
|
|
#2 |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 770
Rep Power: 3
![]() |
I comment as I see fit. If a function isn't easily described in its name, or has handling issues, I'll comment it. Same with sections of code. But that's about it.
|
|
|
|
|
|
#3 |
|
Programmer
Join Date: May 2006
Posts: 85
Rep Power: 3
![]() |
Me too. I hate cluttering up my code with uneeded comments.
__________________
Code Forums |
|
|
|
|
|
#4 |
|
Professional Programmer
|
If it's just something quick that will never be used again, nobody will ever see, and never has a chance of being maintained, I won't comment.
|
|
|
|
|
|
#5 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
I always comment (javadoc in Java, docstring in Python) every function I make. Whether I comment inside depends on the complexity.
|
|
|
|
|
|
#6 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,261
Rep Power: 5
![]() |
I generally seek to write code in a manner that avoids unnecessary comments. For example, picking names of variables/functions/types well can mean the code itself is its own documentation; comments are then less necessary.
The only exception will be if it is necessary to keep an audit trail of modifications to a function: then comments will keep track of the history of changes to a function, who did it, when, why, etc. There are also cases where things have to be done in non-obvious ways, so it is then a good idea to comment code. For example, working around compiler bugs, using hand-crafted code to tweak performance via bit fiddling rather than using mathematical operations, or doing things that are compiler specific. Even then, I will seek to avoid comments by putting such constructs into their own inlined functions so someone looking at the function can work out what it does from the name, even if they don't understand the obscure operations inside it. I actually use more comments in code posted to forums like this than I would ever want to see in production code, because it is often more necessary to explain things that would be taken for granted in a professional environment. |
|
|
|
|
|
#7 |
|
Hobbyist Programmer
|
every function has to have pre and post conditions stated, what its intent is and how it is called. all variables are labeled and explained. any step that is not simple needs some form of explanation as to be easily understood when reading the comments.
that is waht i have to do from some of my classes. it's a pain and does tend to cluter things up. but it sure helps you know whats going on in the code 6 months latter when you come back to it.
__________________
i dont know much about programming but i try to help |
|
|
|
|
|
#8 | |
|
Sexy Programmer
|
Quote:
__________________
I would love to change the world, but they won't give me the source code! |
|
|
|
|
|
|
#9 |
|
Programmer
Join Date: May 2006
Posts: 85
Rep Power: 3
![]() |
True going back to un-commented code can be kinda hecktic...
__________________
Code Forums |
|
|
|
|
|
#10 |
|
SEXY SHOELESS GOD OF WAR!
![]() Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,198
Rep Power: 5
![]() |
My mindset is similar to grumpy's regarding comments. I like using names that are long enough to be clear, which, when coupled with a good coding style, act as implicit commenting. However, I do put a comment above the definition/declaration for each function, because even if the general purpose of the function is clear from its name, its exact semantics may not be. Notes to myself (for example, in a function that still needs tweaking) go here, too. Actual function bodies get few (if any) comments, unless they use code that is easy to misinterpret.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|