-2

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 :)

Liane
  • 111
  • 10

3 Answers3

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
1

Read

10 Best Practices to Follow while writing Code Comments

Nidheesh
  • 4,390
  • 29
  • 87
  • 150
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