在编写“库”类型类时,是否最好总是在java中编写标记文档(即javadoc),或者假设代码可以是“自动记录”的?例如,给出下面的方法存根:应该记录API的所有公共方法吗?
/**
* Copies all readable bytes from the provided input stream to the provided output
* stream. The output stream will be flushed, but neither stream will be closed.
*
* @param inStream an InputStream from which to read bytes.
* @param outStream an OutputStream to which to copy the read bytes.
* @throws IOException if there are any errors reading or writing.
*/
public void copyStream(InputStream inStream, OutputStream outStream) throws IOException {
// copy the stream
}
的Javadoc似乎是不言而喻的,而且只需要如果funcion在所有改变为更新的干扰。但关于冲洗和不关闭流的话可能很有价值。
因此编写库时,是最好的:
一)始终记录
二)文档任何不明显
C)从来没有记录(代码应该为自己说话)
我通常使用b),我(因为代码可以自我记录,否则)...
对不起,编辑标签,但我想确保你显示在最流行的云,而不是创建多余的标签。 – Sean 2008-09-25 02:29:44