top | item 47137108

(no title)

NoNameHaveI | 5 days ago

I'm glad to see there is a "Beyond the Code" section that discusses comments. Here's what I typically told my students in Intro to Programming" Good comments lend insight into the code. Reading the code itself tells you the what. Comments should explain the why. Comments like "i+=1; /* Increment i */" are of little value. However comments such as "We increment i mid loop so that we can peek ahead at the next value for a possible swap" are more useful. Use a narrative voice when writing comments, like you are explaining the code to your grandparent. This make digestion easier. Remember, code spends most of its life, and most of its expense, in the maintenance phase. The easier you make your code to understand, the less it will cost and the longer it will live.

discuss

order

dec0dedab0de|5 days ago

I prefer comments like "I'm sorry about this, I know it's ugly but I'm in a rush and it's the quickest way to get it working"

stronglikedan|5 days ago

As long as there's a "TODO" tag in the comment to easily search for, then I prefer those comments as well.

jimbokun|4 days ago

Would your Grandma approve of you introducing that technical debt?

That’s why it’s important to write comments as if to your grandparents. For the feelings of accountability that it engenders.