Comments In Code
hamedh.posterous.com
Comments In Code
1–10 of 10 posts
Re: Comments In Code
#2Re: Comments In Code
#3Sometimes you have to do bad stuff and you should stick a comment in there so that when you come back to that bit in code you are forewarned...
Think of it as hic seunt leones on old maps (here be lions for all the non-latin speakers out there...)
Re: Comments In Code
#4Re: Comments In Code
#5Re: Comments In Code
#6When I'm learning a language I write comments for myself. Notes about syntax, idioms, gotchas, and whatever else.
When I'm fixing a problem I leave XXX markers around to easily keep track of what I'm doing.
When I'm writing maintenance code I reference the ticket number, describe the problem or feature, and why we implemented the fix or feature the way we did.
You should never see the first two types of comments in checked in code, but I bet that I've probably saved later maintenance programmers hours of frustration with that last type of comment.
Re: Comments In Code
#7Re: Comments In Code
#8I'll just leave this here: http://zachholman.com/posts/documentation/
Re: Comments In Code
#9> Code should be almost as readable as a book. You should be to read without pausing too much as well as skimming.
I pause much more reading code than I do reading prose.
Trying to keep a lookup table of functions and variables in my head is much harder than reading a few lines of prose to let me know what's going on.
Comments should summarise what's going on, so that when you have a bug, you can jump to the right section to change.
> Comments are almost like an annotation in a book. So use them sparingly.
The way I think of it: Don't use comments to annotate your code. Use code to annotate your comments.
Re: Comments In Code
#10This discussion is one that will never die because people will always have entrenched, dogmatic viewpoints on this. I dislike comments that explain what you're doing. The code should be readable enough to see what you're doing. However having spent over a decade now maintaining code written by people that may not be with the organization anymore, it's always nice to occasionally get context on WHY someone wrote the c…
"Programs must be written for people to read, and only incidentally for machines to execute." - http://mitpress.mit.edu/sicp/front/node3.html