java一般会写javadoc吗_你对你写的每一种方法都使用Javadoc吗?

@Claudiu

When I write code that others will use – Yes. Every method that somebody else can use (any public method) should have a javadoc at least stating its obvious purpose.

@丹尼尔Spiewak

I thoroughly document every public method in every API class. Classes which have public members but which are not intended for external consumption are prominently marked in the class javadoc. I also document every protected method in every API class, though to a lesser extent. This goes on the idea that any developer who is extending an API class will already have a fair concept of what’s going on.

Finally, I will occasionally document private and package private methods for my own benefit. Any method or field that I think needs some explanation in its usage will receive documentation, regardless of its visibility.

@保罗德Vrieze

For things, like trivial getters and setters, share the comment between then and describe the purpose of the property, not of the getter/setter

/**

* Get the current value of the foo property.

* The foo property controls the initial guess used by the bla algorithm in

* {@link #bla}

* @return The initial guess used by {@link #bla}

*/

int getFoo() {

return foo;

}

是的,这是更多的工作。

@VonC

>一个公共方法调用

>几种私有方法,代表公共内部步骤

,它对javadoc的私有方法也非常有用,即使该文档在javadoc API文件中不可见。

仍然,它允许您更容易记住您的复杂算法的不同步骤的精确性质。

另外,javadoc比简单的“// comment”更好:

>它由IDE识别,用于在将您的光标移动到其中一个 – javadoc-ed – 函数之上时显示一个弹出窗口。例如,一个常量 – 即私有静态最终变量 – ,应该有一个javadoc,尤其是当它的值不是微不足道。例子:regexp(它的javadoc应该包括其非转义形式的regexp,什么是目的是和regexp匹配的文字示例)

>它可以通过外部工具(如xdoclet)解析,

@Domci

For me, if somebody will see it or not doesn’t matter – it’s not likely I’ll know what some obscure piece of code I wrote does after a couple of months. […]

In short, comment logic, not syntax, and do it only once, on a proper place.

@Miguel Ping

In order to comment something, you have to understand it first. When you trying to comment a function, you are actually thinking of what the method/function/class does, and this makes you be more specific and clear in your javadoc, which in turn makes you write more clear and concise code, which is good.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您好!感谢您的提问。根据您的问题,我理解您想要将一个Java项目的Javadoc转移到另一个Java项目的Javadoc中。如果我的理解有误,请让我知道。 要将一个Java项目的Javadoc转移到另一个Java项目的Javadoc中,您可以按照以下步骤操作: 1. 在源代码中为您想要转移的类和方法添加Javadoc注释。您可以使用以下示例注释格式: /** * 这是一个示例方法。 * @param param1 参数1 * @param param2 参数2 * @return 返回值 */ 2. 使用JavaDoc工具生成Javadoc文档。您可以使用以下命令生成Javadoc文档: javadoc -d [输出目录] [需要生成文档的Java文件] 例如: javadoc -d /home/user/myproject/doc -sourcepath /home/user/myproject/src com.example.myproject 这将生成一个名为index.html的Javadoc文档文件,可以在浏览器中查看。 3. 将生成的Javadoc文档复制到您想要转移的Java项目中。您可以将生成的Javadoc文档文件夹复制到您想要转移的Java项目的根目录下。 4. 在目标Java项目中使用Javadoc注释中的@see标签引用源Java项目的Javadoc文档。例如: /** * 这是一个示例方法。 * @param param1 参数1 * @param param2 参数2 * @return 返回值 * @see com.example.myproject.ExampleClass#exampleMethod */ 这将在Javadoc文档中为该方法添加一个“参见”链接,该链接指向源Java项目中的ExampleClass类和exampleMethod()方法。 希望这些步骤能帮助您将一个Java项目的Javadoc转移到另一个Java项目的Javadoc中。如果您有任何其他问题,请随时问我。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值