Google Code Prettify

2015年5月16日 星期六

Journal Comments

Journal Comments」是 Clean Code 書中的一個小章節 (Robert C. Martin 著),原文如下,大意是,以前沒有版本控管軟體的年代,程式員會在程式的一開頭寫上一段註解,用來說明程式的變更歷程,現在有了版本控管軟體 (svn、git...),只要在將程式碼 commit 到版本控管軟體前,寫下程式做了什麼變更,之後就可以由版本控管軟體的 log 或 history 裡,輕易的查到各個版本,還可以輕易的比對各版本間的差異,比起這些註解好用且實際,既然有了這麼方便的工具,就將這些註解『全部』拿掉吧! 因為這些註解只會讓程式顯的雜亂無章!

(或許我有點過度解釋了原文,但是,應該沒有曲解原文的意思吧?)

----- 以下為原文 -----
Sometimes people add a comment to the start of a module every time they edit it. These comments accumulate as a kind of journal, or log, of every change that has ever been made. I have seen some modules with dozens of pages of these run-on journal entries.


Long ago there was a good reason to create and maintain these log entries at the start of every module. We didn’t have source code control systems that did it for us. Nowadays, however, these long journals are just more clutter to obfuscate the module. They should be completely removed.


沒有留言:

張貼留言