Stop Using TODO for Everything (停止使用 TODO 處理所有事情)
很多程序員習慣在代碼注釋寫 TODO,表示待完成的任務。作者建議不要再寫 TODO,而用具體的任務替代,比如需要添加文檔寫"DOCME",需要添加測試寫"TESTME"。
并不是說“注釋不好”,或者“你應該只使用問題跟蹤器”。而是有一些方便的,更具描述性的替代方案:
| Term | Indicates... |
|---|---|
| FIXME: | something is broken (意味著代碼還需要修改) |
| HACK/OPTIMIZE: | the code is suboptimal and should be refactored (功能雖然實現了,但是還有待商榷) |
| BUG: | there is a bug in the code |
| CHECKME/REVIEW: | the code needs to be reviewed (方便在code review時與人討論) |
| DOCME: | the code needs to be documented (either in codebase or external documentation) |
| TESTME: | the specified code needs to be tested or that tests need to be written for that selection of |
這種TODO標簽在vim中叫 task age;
Eclipse中也使用這種任務標簽:TODO, XXX,FIXME。
IDEA 中也可以通過Preferences > Editor > TODO來自定義匹配:

效果:


浙公網安備 33010602011771號