• Post Reply Bookmark Topic Watch Topic
  • New Topic

Effect of multiline or single line comments before method header  RSS feed

 
H. J. Yoshi
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

What is the effect of placing single line/multiline comments in a java file before message header (with javadoc comments) have? I have observed that in WSAD it does interfere.. but I do not understand how far reaching/severe/important is this effect.

Please help with the issue..
 
Anu Pillai
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you mean the comments that appear on top of a method when we create it using an IDE, then they are the ones which appear in the JavaDoc when you create one for that class. These are the description that you read in the API of the classes. The IDE provides space for you to describe what a method does, what are its input paramaters and its output parameters. So that when any other person reads the code, he gets an idea about the method or the class.

Example
 
David McCombs
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In what way have you observed an effect to the program?

The compiler ignores any comments so any effects should be nil.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by David McCombs:

The compiler ignores any comments so any effects should be nil.


@deprecated comments *do* have a (minor) effect on the compiler...
 
H. J. Yoshi
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks David and Ilja.
I faced the problem first when:

I checked in some files with single line comments in Rational Clearcase.When I downloaded the same code after some time it was full of compilation errors because some code (Method definitions and variable declarations) moved behind single line comments.That is new characters were not being recognized.. The files appear exactly same in WSAD editor/Textpad so this error can not creep in WSAD. Could be an issue with clearcase..

And two, in WSAD: If I write a method say-



Then if I type '/**' in the line above this method definition and press 'Enter' following comment isgenerated.


But, if I precede the above method with any other comment this behavior is not exihibited. For ex. following comment is generated if i carry out the above mentioned step..i.e without the '@' ..



This makes me think that presence of nay other comment might .. again I am not sure what.. but it has some effect..

Ilja,is the problem because of @ comments..? These are all over in the files I faced the issue with. Pls help..
And thanks again..
 
David McCombs
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assumed you meant compiler issues. It is your IDE that automatically adds the rest of the comments.

/** means the beginning of comments for javadoc. Your IDE probably only does this in the absence of normal comments. Go into the IDE's properties and see if you can change this behavior.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!