I wrote more about this here (it's Lua code, but it applies to any language):
http://kiki.to/blog/2012/03/16/small-functions-are-good-for-...
41–50 of 198 posts
I wrote more about this here (it's Lua code, but it applies to any language):
http://kiki.to/blog/2012/03/16/small-functions-are-good-for-...
Personally I have no problems with comments in code for complex functions etc. But pointless comments like this below drives me insane. // get the user $user = $this->getUser(); Times that by the thousands of lines in a project and you have one big headache!
I hope you have a problem with complex functions. (They should be made as simple as possible).
http://www.haskell.org/haskellwiki/index.php?title=Commentin...
It isn't official in any sense.
I've seen this many times: ...thus they (comments) tend to diverge from actual implementation. It happens, you update/refactor code, and forget to update the comments. Thus the comments are outdated or worse not applicable anymore. Common mistake by less-detailed oriented developers. Begs the question, in this case is is better to have confusing/incorrect comments, or no comments at all?
Personally I have no problems with comments in code for complex functions etc. But pointless comments like this below drives me insane. // get the user $user = $this->getUser(); Times that by the thousands of lines in a project and you have one big headache!
> Personally I have no problems with comments in code for complex functions etc I hope you have a problem with complex functions. (They should be made as simple as possible).
Personally I have no problems with comments in code for complex functions etc. But pointless comments like this below drives me insane. // get the user $user = $this->getUser(); Times that by the thousands of lines in a project and you have one big headache!
> Personally I have no problems with comments in code for complex functions etc I hope you have a problem with complex functions. (They should be made as simple as possible).
This is not convincing to me because the examples are trivial: -- swap the elements of a pair swap :: (a,b) -> (b,a) Yes this is redundant. let b=a+1 -- add one to 'a' Yes this is also redundant Does it mean that every piece of code can be expressed as clearly as in a one-line comment in natural language? I don't think so.
Good code should be self documenting.
Good code needs no test either,... wait no ,that's a stupid thing to say,because nobody writes "good code",code isnt good or bad,it either results in the expected behavior or not.
"In this book we don't use many comments; we try to make our programs self-documenting by using descriptive names."
http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-15.html...
I've seen this many times: ...thus they (comments) tend to diverge from actual implementation. It happens, you update/refactor code, and forget to update the comments. Thus the comments are outdated or worse not applicable anymore. Common mistake by less-detailed oriented developers. Begs the question, in this case is is better to have confusing/incorrect comments, or no comments at all?
No comments are better than bad comments. There is nothing worse than a misleading description.
A bad description isn't just a problem in itself, it can indicate a worse problem sat waiting to jump out and bite as you walk by.