The first question I have is, what are
the guidelines you follow when you
write documentation for a
method/function/procedure? Do you
always do doc-comments or do you try
to let the method names speak for
themselves?
My first goal is always name the methods so anyone can understand what they are supposed to do at first glance. Even though some doc-comments on the method header are a nice addiction, I find it's always better to know what's going on at your code by reading it. Having to search the docs - even by mouse hover - is not as fast as just reading it. I always try to add extra info on the doc-comments, like conditions for each thrown exception and the return type - if I find it's not obvious by reading the method name.
What about within the code block? Do
you find yourself writing a lot of
line by line code? If you do, why do
you feel the need for it?
More often than not, if I find a piece of code that's worth commenting, then it's probably either needless complicated and/or it can/should be extracted into a method of its own. I like to encapsulate minimal functionality on methods, so it's easier to unit test them and make the rest of your code easier to read and understand. Almost every time, the newly created method's name says more than an inline comment, and now you need only to read it out loud to understand what's going on on that part of the code.
What do you think should be the
standard for documenting a small
self-contained chunk of code (as
opposed to the code as whole or
tests)?
Like the code itself, documentation should be also small, but meaningful. I like to keep it brief, document unexpected situations (exceptions) and - if necessary - the return value (if any).
Do you find that your opinions differ
depending on project size/type? On
language you're using? On
documentation tools available?
It's not about the project size, the language I'm using or the doc tools available. I only think an extensive code documentation is valid if you're creating an API that will be used by other developers (of-the-shell components, enterprise libraries and so on), so they can understand the interfaces/methods you're providing without having to hack through your code.