What are the dos' and don'ts in putting comment in eclipse. And one more thing, I'm putting comments on source codes which I didn't make... and I'm having a hard time because I'm a newbie in java as well. Any tips? Thank you :)
Asked
Active
Viewed 333 times
-2
-
With putting comments you mean just adding comments to your code? – markusthoemmes Feb 06 '14 at 09:46
-
Comment in `Eclipse`? Or did you mean comment in your Java code? – Some guy Feb 06 '14 at 09:47
-
And as for adding comments in files that you did not write, refer to your peers or company policy. – Some guy Feb 06 '14 at 09:48
-
ctrl+shift+c is the shortcut for commenting a block of code in Eclipse, if that's what you're wondering. – Christofer Ohlsson Feb 06 '14 at 09:50
-
1Maybe this helps: http://stackoverflow.com/questions/1079713/good-example-of-javadoc/1079765#1079765 – boskop Feb 06 '14 at 09:52
3 Answers
2
You can use //
and /* ... */
comments where you like.
There are also /** ... */
which are JavaDoc comments,
and can be processed by external tools for generating
JavaDoc documentation.
See also: JavaDoc
Eclipse or not it does not matter, this is not IDE dependent.

peter.petrov
- 38,363
- 16
- 94
- 159
-
You may read this question on SO as well: http://stackoverflow.com/questions/1079713/good-example-of-javadoc – KrishPrabakar Mar 02 '15 at 06:24
1

Nidheesh
- 4,390
- 29
- 87
- 150
-
2Link only answers are highly discouraged. Might be good as a comment. – Rohit Jain Feb 06 '14 at 09:56
1
I strongly recommend "Clean Code - A Handbook of Agile Software Craftsmanship" by Robert C. Martin
You can read more information there about the following tips regarding dos' and don'ts:
- Comments Do Not Make Up for Bad Code
- Explain Yourself in Code (instead of paragraphs of comments)
- Don’t Use a Comment When You Can Use a Function or a Variable
- Good Comments
- Legal Comments // Copyright (C) 2014
- Informative Comments // Returns an instance of the Responder being tested.
- Explanation of Intent // We return the first element from a list when catching an error during parse
- Clarifcation // assertTrue(a.compareTo(a) == 0); // a == a
- Warning of Consequences // Test purposes only
- TODO Comments // TODO: add support for arrays
- Bad Comments
- Mumbling // No properties files means all defaults are loaded
- Redundant Comments // compares a with b
- Misleading Comments // especially when code is updated and descriptive comments are left behind
- Mandated Comments // @param title The title of the CD
- Journal Comments // you have versioning via SVN, TFS etc, no need to write what has been modified via comments
- Noise Comments // Default constructor
- Commented-Out Code
- HTML Comments
- Too Much Information
- Inobvious Connection // add extra 200 for header info
- Function Headers
- Javadocs in Nonpublic Code

Arnold Waldraf
- 160
- 3
- 13