How do you flag code so that you can come back later and work on it?

前端 未结 23 2078
后悔当初
后悔当初 2020-12-24 11:46

In C# I use the #warning and #error directives,

#warning This is dirty code...
#error Fix this before everything explodes!
<         


        
23条回答
  •  有刺的猬
    2020-12-24 12:19

    It is probably not a good idea to sprinkle your code base with uninformative TODOs, especially if you have multiple contributors over time. This can be quite confusing to the newcomers. However, what seems to me to work well in practice is to state the author and when the TODO was written, with a header (50 characters max) and a longer body.

    Whatever you pack into the TODO comments, I'd recommend to be systematic in how you track them. For example, there is a service that examines the TODO comments in your repository based on git blame (http://www.tickgit.com).

    I developed my own command-line tool to enforce the consistent style of the TODO comments using ideas from the answers here (https://github.com/mristin/opinionated-csharp-todos). It was fairly easy to integrate it into the continuous integration so that the task list is re-generated on every push to the master.

    It also makes sense to have the task list separate from your IDE for situations when you discuss the TODOs in a meeting with other people, when you want to share it by email etc.

提交回复
热议问题