Java 如何管理@todo 编程的东西?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1989177/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to manage @todo programming stuff?
提问by wj.
For many years my code was full of this kind of comments :
多年来,我的代码充满了这种评论:
//TODO : Add ...
...
/*
*TODO : Fix ...
*
*/
Now I think to create my own @todo
javadoc annotation ... but before doing that I want to know if do you guys have better way to manage your todoprogramming stuff ?
现在我想创建我自己的@todo
javadoc 注释......但在此之前我想知道你们是否有更好的方法来管理你的待办事项编程内容?
采纳答案by Bozho
Your IDE (Eclipse, NetBeans, ..) has a tasks plugin, which detects all TODO
s and shows them in a list. In Eclipse it's Window > Show View > Other > Tasks
您的 IDE(Eclipse、NetBeans 等)有一个任务插件,它可以检测所有TODO
s 并将它们显示在列表中。在 Eclipse 中它是Window > Show View > Other > Tasks
No need to write your own annotation.
无需编写自己的注释。
回答by Alberto Zaccagni
For small tasks such as my usual //todo I use local tasks in Eclipse Mylyn, for bigger tasks (even if I think those might be called features or bugs) I use Trac; if you find your code full of TODOs it's time to get a ticket management system.
对于像我通常的 //todo 这样的小任务,我在 Eclipse Mylyn 中使用本地任务,对于更大的任务(即使我认为这些可能被称为功能或错误),我使用 Trac;如果你发现你的代码充满了 TODO,那么是时候获得一个票务管理系统了。
回答by catchmeifyoutry
For vim there is also this Tasklistscript, inspired by Eclipse's task list, which scrapes for TODO, FIXME, etc. in your text files and displays them as a list in an extra buffer (see screenshot).
对于 vim,还有这个Tasklist脚本,其灵感来自 Eclipse 的任务列表,它在文本文件中抓取 TODO、FIXME 等,并将它们显示为额外缓冲区中的列表(参见屏幕截图)。
回答by Fabian Steeg
I basically use three systems for different kinds of TODO items:
我基本上对不同类型的 TODO 项目使用三个系统:
- Paper notepad for short-term items (like today or this week)
- TODO comments plus IDE support (e.g. Eclipse Tasks view) for smaller, longer-term items
- Issue tracker like Trac plus IDE support (e.g Mylyn) for more complex, longer-term items
- 短期项目的纸质记事本(如今天或本周)
- TODO 注释以及 IDE 支持(例如 Eclipse 任务视图),适用于更小、更长期的项目
- 问题跟踪器,如 Trac 加上 IDE 支持(例如 Mylyn),用于更复杂、更长期的项目
回答by ZelluX
Maybe you can use find and grep to search for those keywords in your projects
也许您可以使用 find 和 grep 在您的项目中搜索这些关键字
回答by manuel aldana
problem with todo flags is the same as with warnings (e.g. java compiler, checkstyle). if they appear to often, you will ignore them. in your case i would track them through a report by a build-system (e.g. maven or ant). at the end of each iteration you should make a rule, that the number of todo flags decreases.
todo 标志的问题与警告(例如 java 编译器、checkstyle)的问题相同。如果它们经常出现,您将忽略它们。在您的情况下,我会通过构建系统(例如 maven 或 ant)的报告来跟踪它们。在每次迭代结束时,您应该制定一个规则,即减少待办事项标志的数量。
less todo-flags means:
更少的待办事项标志意味着:
- solving them
- delete them because they got obsolete (which happens often if you never tidy up code)
- 解决它们
- 删除它们,因为它们已经过时了(如果你从不整理代码,这种情况经常发生)
generally don't use todo flags for all tasks. for me they are just little reminders or refactorings-todos. bigger tasks should always be tracked by a ticket-system (like trac or jira).
通常不要对所有任务都使用 todo 标志。对我来说,它们只是小小的提醒或重构 - 待办事项。更大的任务应该始终由工单系统(如 trac 或 jira)跟踪。
回答by Johan
Maybe Doxygen can help you?
也许 Doxygen 可以帮助你?
Doxygen recognise those ///@TODO:s and creates a list with them.
Doxygen 识别这些 ///@TODO:s 并用它们创建一个列表。
And since Doxygen can use Javadoc style comments, I guess it is kind of easy to try it.
由于 Doxygen 可以使用 Javadoc 样式的注释,我想尝试一下会很容易。
回答by wheaties
If your TODO statements are bugging you that much and causing you that much angst when seeing them I'd write a small script in the build process that detects and fails the compilation. Have it fail in the same way that it fails on warning statements.
如果您的 TODO 语句让您如此烦恼并在看到它们时引起您如此多的焦虑,我会在构建过程中编写一个小脚本来检测并失败编译。让它以与警告语句失败相同的方式失败。
回答by Sam Barnum
I use FIX! instead of TODO. The number of exclamation points indicates the priority. IntelliJ lets you set up custom filters for these, so I can look at level-3 "FIX!!!" comments and tackle those.
我用FIX!而不是 TODO。感叹号的数量表示优先级。IntelliJ 允许您为这些设置自定义过滤器,因此我可以查看第 3 级“修复!!!” 评论并解决这些问题。
回答by user85421
I would not use a @todo
javadoc annotation because IMO it should'nt go into the documentation.
Documentation should be public, not ideal for TODOs.
TODOs should also go near the code they relate to, an advantage of using comments.
我不会使用@todo
javadoc 注释,因为 IMO 它不应该进入文档。
文档应该是公开的,不适合 TODO。
TODO 还应该靠近它们相关的代码,这是使用注释的一个优势。