|
Joergen Sigvardsson wrote: i *= 4; // Multiply by 4
That should be:
i *= 4;
|
|
|
|
|
The long version would be:
The even longer version contains an essay about caching and all its consequences. The longest one includes a powerpoint animation of the CPU die transistors going on and off....
|
|
|
|
|
But what about methods? It drives me nuts when I see a routine with no comment, especially if that routine has a name like "HandleAction" that tells you nothing.
I find it so easy to get into the deadly "I understand it therefor it should be obvious to everyone else" trap.
cheers,
Chris Maunder
CodeProject.com : C++ MVP
|
|
|
|
|
A better solution is using meaningful names, then you may not need the comment at all
|
|
|
|
|
I agree. If the methods and variables have poignant names, comments become superfluous and that's one less thing to update if the code is changed.
IMO, excessive commenting probably means the code is either of questionable quality, or the developer has a hard-on for comments.
I find the best way to write comments, is to re-visit classes after a few weeks (once I've forgotten the thought processes behind it all) and read it from a virgin perspective. That way, I'm more likely to place comments where really needed. The trick is reading it from someone else's point of view.
"And when I have understanding of computers, I shall be the Supreme Being!"
|
|
|
|
|
mungflesh wrote: I find the best way to write comments, is to re-visit classes after a few weeks
I have been known to do the same thing and often try to anticipate the need. Nothing like reading your old code and saying “why did I do that?” to see a comment is (was) required.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
mungflesh wrote: IMO, excessive commenting probably means the code is either of questionable quality, or the developer has a hard-on for comments.
That's worth a 5
Grim (aka Toby) MCDBA, MCSD, MCP+SB
SELECT * FROM users WHERE clue IS NOT NULL
GO
(0 row(s) affected)
|
|
|
|
|
Chris Maunder wrote: It drives me nuts when I see a routine with no comment, especially if that routine has a name like "HandleAction" that tells you nothing.
Ditto! It's also amazingly common to have wishy-washy names such as HandleAction. It can be OK when we're being very generic, e.g., in some kind of framework. but more often than not it's because the dev can't be arsed to think up a better name.
Kevin
|
|
|
|
|
problem sync code with old comment?
|
|
|
|