Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

D.T.

macrumors G4
Sep 15, 2011
11,050
12,460
Vilano Beach, FL
You write comments to describe why you are doing something not how. No amount of refactoring is going to describe why you chose a given algorithm or why you chose to perform a given task in a certain way.

Remember you don't comment code to describe what the code does. You comment code to describe why the code does what it does.

It sounds to me like you don't know how to comment code effectively or haven't worked on code that uses comments effectively. I can always read the code to see what it does but no amount of reading the code tells me why it was done the way it was.


Yeah, my comments tend to be business rules, justification, or I suppose you could call it "supporting logic”. They’d be applicable regardless of the language or implementation. On [rare] occasion, I might clarify some code specific item (especially if it’s some less than obvious workaround).


I find it much more important to comment my methods than the interior lines of code. On rare occasion I'll comment a bit of interior code but not too often.

A coworker I had a long time ago commented nearly every line of code and it was maddening. I kid you not, above an i++ statement they had commented:

Code:
// increases the value of i by 1
i++;

I didn't feel good enough yet in my skills to thwap them over the head but these days I would have had a sit down with them.

Hahaha, who would’ve thought the funniest thing I read all morning would be in the programming section on an Apple rumors site. :D
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.