eclipse modify the default comment template


A good comment

Rich annotation and good coding standards for readability and maintainability of the code plays a vital role. Almost every company these requirements is quite strict, tend to form their own set of coding standards. However, in the implementation process, if done manually thanks, not only inefficient, but also difficult to ensure true compliance. So the combination of IDE environment, automatically generate comments, or necessary. This article describes the use Eclipse to create a custom template code comments.

Second, the need to follow the rules of good comments

  • Good comment is no comment 让代码具有自解释function.
  • 注释要精炼Do not nonsense, not too long, do not simply repeat.
  • 提供信息The comment is a good comment. Some comments just translate the code, it does not indicate the purpose of the code and other useful information.
  • TODO注释也是好注释, Some portions of the code to alert the programmer is not completed.
  • For 公共的API需要提供好的Javadoc.
  • 不要注释代码. Later commented code will give people a very important sense, others are not deleted, in the end will produce code that contains a lot of nasty comments.
  • 不要万物皆注释
  • To write a comment after 时常更新.

Third, set the comment template

eclipse: Window-> Preference-> Java-> Code Style-> Code Template
Here Insert Picture Description
below Amway few places, add comments more comfortable.

(1) (Note class) Types comment tag

/**
 * 类说明:
 *
 * @guoqianliang1998.
 */

(2) Method comment tag (annotated Method)

/**
 * 方法说明:
 *
 */
Published 346 original articles · won praise 912 · Views 150,000 +

Guess you like

Origin blog.csdn.net/weixin_43691058/article/details/104039425