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
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值