java中到底該不該用@author標識作者?

今天查看activiti的README,突然發現一段很有意思的FAQ。

Why do you not accept @author lines in your source code?

    Because the author tags in the java files are a maintenance nightmare
        A large percentage is wrong, incomplete or inaccurate.
        Most of the time, it only contains the original author. Many files are completely refactored/expanded by other authors.
        Git is accurate, that is the canonical source to find the correct author.

    Because the author tags promote code ownership, which is bad in the long run.
        If people work on a piece they perceive as being owned by someone else, they tend to:
            only fix what they are assigned to fix, instead of everything that's broken
            discard responsibility if that code doesn't work properly
            be scared of stepping on the feet of the owner.

    Credit to the authors is given:
        with Open Hub which also has statistics
        in the GitHub web interface.

問題:爲什麼不在源碼中使用 @author ?

首先,@author 是什麼?

Java 文檔註釋標籤。
其他常用的有:

@author 作者
@param 輸入參數的名稱 說明
@return 輸出參數說明
@since JDK版本
@version 版本號
@see 鏈接目標
@throws 異常
@deprecated

爲什麼不用?

activiti作者認爲:

  • 不利於java文件的後期維護。
  • 對於長久來說,爲代碼標明所有者是很糟糕的事情。
  • 代碼版本工具提供了作者的提交歷史記錄,不需要再單獨標識。

我覺得說的很有道理!

但是,公司內部的管理來說,有些人就是喜歡打上程序員的標籤。
好吧,全世界的問題都是程序員的錯!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章