在編寫「庫」類型類時,是否最好總是在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