|
|
In that case, you need comments right?
|
|
|
|
|
Our shop documents the business process outside the code base about 99.9% of the time, and this is for the complex business processes. We don't use our code base to document code.
Besides, you are not allowed to even look at our code, until you have read the business docs, design docs, etc., and understand the overall system.
So, we use comments in code....about .1% of the time....and it is not a "need".
|
|
|
|
|
The robot overlords are presumably bright enough to understand my code even without comments, and by the time the paleontologists take an interest in me or my code, I expect to have been long retired.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
Do robot overlords have a sense of humour? I sincerely hope so...
We're philosophical about power outages here. A.C. come, A.C. go.
|
|
|
|
|
Who do you write comments for? really? Is this noob hour?
|
|
|
|
|
Slacker007 wrote: Is this noob hour? Judging from the comments I've read over the past six years, no, it's not noob hour, it's a noob age...
|
|
|
|
|
One thing I love about polls is that you start with an expectation of what the answer is and watch as you're proven wrong.
Open your mind a little to the possibility that what you feel is self-evident may, in fact, be not.
(And while you're at it you can put your money where your mouth is[^] )
cheers
Chris Maunder
|
|
|
|
|
|
Apparently, you don't have knowledge about research and polls. Information you don't care is valuable for researchers. I didn't know that until I've worked for a research company, you'd be surprised the statistics they generate from simple answers...
|
|
|
|
|
In earlier time comments were written to enhance the LOC counter.
//TODO: check when this was modern
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Just like some of the formatting rules requiring even rather simple statements such as
if (x<0) y=0;
using brackets on their own separate lines and a blank line after it:
if (x < 0)
{
y = 0;
}
<blank line>
That increases your productivity by a factor of five!
|
|
|
|
|
Quote: Who do you write comments for? To guide ego-ed person like you. . Adding on top what other said, You really need comments when a logic is complex one writing a code only won't help.
|
|
|
|
|
By default, code commenting is off.
Whenever I write a piece of WTF code I first rewrite it. If that's not possible I might comment.
I'm so sick and tired of code comments that just sit there being useless (which is 99.999999% of all code comments I've come across)...
I've said enough about that in my time here on CP though[^]
|
|
|
|
|
Sander Rossel wrote: I'm so sick and tired of code comments that just sit there being useless (which is 99.999999% of all code comments I've come across)...
The other 0.000001% can save many hours, though.
I'm very sparing with comments but if it's something I've had a major battle and hours on Google to resolve, I'll always stick an explanation in.
Yes, we've all seen
//return
return;
at some point in our lives and marveled at the idiocy of it, but every now and again a well judged comment can save us a from a whole world of pain.
|
|
|
|
|
PeejayAdams wrote: but every now and again a well judged comment can save us a from a whole world of pain I have yet to see such a comment
|
|
|
|
|
Sander Rossel wrote: I have yet to see such a comment
You're yet to see my code
|
|
|
|
|
There are two options here:
Your code is so weird you have to constantly comment it...
Or your code is fine and you're just commenting the obvious.
Make your pick
|
|
|
|
|
This did actually get me wondering how many inline comments I actually use. Looking through some open projects, it appears that I use far fewer than I'd have imagined but I certainly wouldn't remove any of those that are there. I always work on the basis that tomorrow I'll have forgotten something that I knew today.
I very much concur with Chris's comments about the 100%
|
|
|
|
|
The existence of one good comment does not justify the existence of the other 9,999,999 useless ones, though. By all means, add the good one, but for the love of the gods, skip the other wastes of space.
|
|
|
|
|
!00% agree that comments need to be meaningful.
However, I present my rebuttal as to why comments are necessary[^].
It's not about writing meaningful comments. It's about writing comments that are meaningful to everyone across time. The "but this is obvious" trap has caught us so many times that I had no choice but to insist on
a) method and parameter comments, even when "obvious".
b) inline comments on anything not blindingly obvious.
Sometimes you just have to write complicated code., and sometimes you have to write code that looks like it's totally unnecessary. Maybe you're optimising, maybe you're working around an issue that happens 1 in a thousand times and everytime you see the code you need reminding that it's there for a reason.
One comment I will make is that, 100% of the time, it's dangerous and outright wrong to make statements along the lines of "100% of the time".
cheers
Chris Maunder
|
|
|
|
|
Chris Maunder wrote: I present my rebuttal as to why comments are necessary[^]. You do make a good point. What's obvious to me now may not be obvious to others now and/or later or myself later. When you comment everything at least it will be clear to everyone always.
Except that commenting isn't easy and many programmers aren't very good at it.
A lot of comments I've read are just the name of a function, but properly spaced and capitalized. Or really state the obvious, like "assign the variable" (really, I've seen multiple programmers do it... why would anyone comment that? ).
And comments are just lines of code that need to be updated, something you can't test for and which is easily, and often, forgotten.
In all the projects I've worked on so far I've learned to ignore comments because never ever ever have they actually helped me. Only when I'm really stuck and I see a comment somewhere do I read it, only to be disappointed once again.
A lot of comments I read aren't even true, they're downright lies and, if anything, confuse rather than help!
Worst case scenario, a comment makes good sense (a rare case indeed), but the code doesn't do what the comment says it does, now who's right?
I can remember a few times where I have commented code.
One was a timer that should trigger at 11:00, but triggered a few milliseconds early. Upon completion I got the next time at which it should run which was... 11:00! And it immediately triggered again. After days of debugging (where the problem never occurred) I found out the milliseconds were the problem. Fix and comment.
Another was with Crystal Reports where getting a property on an object caused the whole object to drop its state (the connection string was reset etc.) rendering it useless...
That's some of the weirdest sh*t I've seen, so that's when I wrote a comment.
Other than that I mostly remember deleting comments like "assign the variable", "Save the customer" (above the line customer.Save(); ), "Save the customer" (above the line product.Save(); ), "Helper variable" (above the line string helper; ), etc...
So if I have to pick between 95% useless comments that annoy me to no end and 5% comments that may be helpful someday or no comments at all I'd go for no comments at all. I'm pretty sure I can figure out that weird piece of code if ever the need be
You DO make a good point though and I can understand why you'd work that way.
|
|
|
|
|
I agree that the boiler plate code, CRUD and the blindingly obvious, does not need commenting.
However a complex piece of coding requires not just what you did but more importantly WHY you did it. The number of times I have sat there scratching my head wondering WhyTF I would write such an abomination, and THEN I read the comments and the memory kicks in. I may still shudder with despair but at least I know why.
I also comment in a URL to any tasty bit of code I have snaffled from the interwebs, let some other poor sod do the doco
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
/* This line has to come here for some reason for the system to startup... do not remove!!! */
"Program testing can be used to show the presence of bugs, but never to show their absence."
<< please vote!! >></div>
|
|
|
|
|
I don't expect people to write down comments too. I just make meaningful name to my variable and function.
|
|
|
|