http://java.sun.com/docs/codeconv/html/CodeConventions.doc4.html#286
I was reading the above section of Java coding convention and started to wonder why it says \"// com
It makes modifying and formatting long comments extremely painful.
Most editors provide some sort of wrapping facility to automatically wrap text into lines of readable length. If every line starts with a '//' those will get moved around, then have to be deleted, and new ones re-inserted. All that tedious work can be avoided using '/* */ style comments.
Actually, I've been using //
for multiple lines for years and never suffered any serious problem with it. I'm not a big fan of /*...*/
anymore because you get:
/* I'm commenting out all this code for a moment
...
/* And here is a multi line comment
that was hidden in the middle */
...
*/
Thank the compiler it gets upset and tells me of the problem.
Where as:
...
// And here is a multi line comment
// that was hidden in the middle
...
becomes with a single macro:
// ...
// // And here is a multi line comment
// // that was hidden in the middle
// ...
and is happily reversed with another single macro that returns it back to the original form
and as for:
// but now you have
// trouble edditing
// your comments so
// that every line
// is of equal size
I say:
// Tough, this is a piece of code not a
// published novel
// and if varying lengths
// make
// it hard for you to read then heaven
// forbid how you handle the code
And don't you just hate edditing:
/******************************************************************
* Program: Foo.java *
******************************************************************
* Author: Codey Art Work *
* Purpose: To do something with something and get something not *
* forgetting something else. *
******************************************************************
* Revision History: *
******************************************************************
* Date | Author | *
*--------|--------|----------------------------------------------*
* 1/2/09 | Jack | Now I have to keep all my comments in this *
* | | tiny little space and if I edit it I just go *
* | | aaarrrrrrggggggggggghhhhhhhhhhh!!!!!!!!!!!!! *
******************************************************************/
which always seem to appear in places insisting on /* */
over //
And I'd just like to say to the Stack Overflow guys, this is really cool editor. Doing code samples is so easy.