CodeThatDocumentsItselfSoWellItDoesNotNeedComments
thedailywtf.com
CodeThatDocumentsItselfSoWellItDoesNotNeedComments
1–10 of 40 posts
Re: CodeThatDocumentsItselfSoWellItDoesNotNeedComments
#2Re: CodeThatDocumentsItselfSoWellItDoesNotNeedComments
#3Re: CodeThatDocumentsItselfSoWellItDoesNotNeedComments
#4I would rather support that, than most of the code I've actually been asked to support.
EDIT: Hear, hear.
Re: CodeThatDocumentsItselfSoWellItDoesNotNeedComments
#5But really, like pmichaud said, I'd rather support this than, say, reverse engineer Google Analytics code http://www.google-analytics.com/ga.js
Re: CodeThatDocumentsItselfSoWellItDoesNotNeedComments
#6After many years of maintaining large codebases written by other people, the comments are very seldom useful, and often actively misleading, thanks to code changes over time. Coders seem a lot more reluctant to change a function so it no longer does what the name implies than they are to modify code without updating the comments.
Re: CodeThatDocumentsItselfSoWellItDoesNotNeedComments
#7I would rather support that, than most of the code I've actually been asked to support.
Re: CodeThatDocumentsItselfSoWellItDoesNotNeedComments
#8I'll come out of the closet and admit that I like descriptive names. There's a point they get ludicrous, but that's also a very clear sign the concept they're representing has become confusing and unwieldy too. If you can't come up with a name that's both clear and short, maybe the function's purpose is also unclear. After many years of maintaining large codebases written by other people, the comments are very seldom…
As for comments though, in my experience they can be extremely useful. And I don't mean just one liner's but a couple sentences here and there explaining what you're doing and why you're doing it.
Agree with you also though, that often a coder working with someone else's base won't take the time to do it. I think this is because we naturally take less pride in maintenance work then we do in the creation of an application.
Re: CodeThatDocumentsItselfSoWellItDoesNotNeedComments
#9This example is only really annoying because the items were almost full sentences. I prefer small 2-3 word functions. But really, like pmichaud said, I'd rather support this than, say, reverse engineer Google Analytics code http://www.google-analytics.com/ga.js
But seriously, two to three word functions and variables aren't bad. Technically though C++ variables have a max size of 255 characters. At least that is what I seem to remember. Am I right?
Re: CodeThatDocumentsItselfSoWellItDoesNotNeedComments
#10I would rather support that, than most of the code I've actually been asked to support.
Is it really all that difficult to throw in a comment explaining what it is you're trying to do when it's not obvious to someone other than yourself?
I've spent way too many months digging around in Fortran code where every variable and function name was less than eight characters (actually the eight-character limit has been gone since Fortran 77, but some people still insist on writing Fortran 90 as if it were Fortran 4).