Commenting, why
It’s smart to comment code as much as possible because you never know when you have to make changes to methods or to study what that method did do before checking method by line by line. Then again commenting things that does not matter make comments not good. Comments should be precise, specific and short. Then again if comment’s are too short and it also might backfire. All in all, adding comment is always better than not setting it all if there are custom tailored coding done.
With Eclipse, it’s easy to add pre-determinated templates with custom comments.
Also commenting can also be helpful for other coders who might one to make changes or just study your code. you also might have it useful when rethinking the methods or class purpose. You might also remember much better what method does when you have couple lines of comment.
Adding commenthing in Eclipse
In order to this in Eclipse IDE go to:
Window -> Preferences -> Java -> Code Style -> Code Template
Here you can found all pre-determinated and automatically added templates. For example, if you wish to since and author values to class when making javadoc comment you can write
/** * @author ${user} * @since ${date} * * ${tags} */
You are also able to add much more stuff, for example if you would like to mention about type of the attribute in setter method add
/** * @param ${param} Type:${field_type}, the ${bare_field_name} to set */
Warn missing comments
You are able to make Eclipse automatically warn you missing comments. To do this go to
Window -> Preferences -> Java -> Compiler -> Javadoc
Then in Eclipse you can see this both in editor and in markers tab
Conclusion
Setting up with commenting with Eclipse isn’t actually that hard but it takes sometime to do it. Moreover it’s more about user to add comments that actually matter. Comment’s can be handy when checking methods, learning other codes and back coding methods or making changes.