views:

437

answers:

9

One of the known problems with //TODO comments is that they tend to get "lost in the code" and are often never returned to.

One usually finds them when searching the source code, or when actually going through the IDE task list (e.g., in Eclipse).

Of course, bug reports are easier to find, but research shows that developers aren't really winning to open a bug report for every little thing.

So my question is this: suppose that you're using the IDE and:

1) Every //TODO comment is highlighted better (e.g., surrounding box or background) instead of the current low-key color and small icon in the side.

2) Every call to a method that has a //TODO comment is highlighted in some way, to let you know that the code you are looking at depends on something unfinished.

Would that be useful and make you more likely to fix problems (to get rid of the marking or to make sure your code doesn't depend on anything broken), or would that annoy the hell out of you and make you turn the darn thing off?

[EDIT: My question is directed at those who do use //TODO comments. I am well aware of their evils, but research does show that many people do use them because bug reports are too expensive/visible] and because they plan for these comments to be transient.]

+1  A: 

in .Net, I have R# ... which has a handy To-Do Explorer ... which shows me all of my todos, as well as other things.

MagicKat
Last time that I saw re-sharper, the to-do explorer was a separate window. You could drill it down to look for todos in a specific location, but don't you have to go and explicitly search for it? I'm asking about some sort of visualization within your code editor.
Uri
and your //TODO //HACK //NOTE //BUG all turn blue as well
MagicKat
Like in Eclipse... But do they only turn blue when they're on the screen, or also when you're using code that depends on a broken method?
Uri
They turn blue on the screen (why would they be blue off the screen ...), the explorer does solution wide (you don't need to file open to see the todo in the todo explorer)
MagicKat
I meant, if you have method X that calls method Y, and method Y is not on the screen but has a todo, do you get some feedback when you're viewing X? I haven't worked with .NET for a few years now. I am familiar with the re-sharper.
Uri
ah ... THAT is what you meant. No it doesn't.
MagicKat
+2  A: 

Our API docs are auto-generated into HTML from source code comments, and (if properly formatted) todo comments are listed in a todo page. They are still generally ignored.

Mark Roddy
But wouldn't your clients be the ones reading the API docs? Assuming they don't just use methods based on names.
Uri
Our clients use the end software and don't code against it. Since we have multiple projects that are built on top of eachother, we use them to make it easier to program against another project's API.
Mark Roddy
So you have APIs remaining in your JavaDocs (or equivalents?).Do your internal programmers read all the documentation before using something?
Uri
+2  A: 

Actually, I don't put TODOs in my source code after reading the Gary McGraw security books. Apparently, people who want to exploit your software toggle in on "TODO", "FIX", "bug", and "XXX" tags which are often used by in-code task identification systems.

Instead, I keep a to-do list separate from my source code.

Thomas Owens
I should note that this is just developing a habit. I don't work on anything that people could or would want to break for any gain.
Thomas Owens
Doesn't that cause a problem when you look at a piece of code and don't remember that you had something to do with it?
Uri
That is what a feature/bug tracker is for
Simucal
+2  A: 

Honestly, I don't think //TODO's are a good bug/feature tracking system at all. It is inherently flawed and difficult to keep track of. I think you should use a true Feature/Bug tracker and put the issues into that system. I even think Notepad is better than inline //TODO's.

With that said, I still occasionally do this myself. In visual studio you can view your task list easily enough but really.. I prefer a dedicated repository for these sort of things.

So, no.. I don't think increased visibility would fix the flaws of the inline, comment TODO system.

Simucal
There's a paper I've read last year that shows that most developers (at least in Java) tend to use //todo comments for a lot of little things where an actual bug report (or mylyn) task is too expensive and too public for comfort. I agree that they're inherently flawed though.
Uri
Well stated! See my comment down the line...
Georgi
TODO comments are for things you want to do before the code is checked in - I'd fail a walkthrough if I saw them. So no, a bug tracking system isn't a replacement, because you don't normally use one to track bugs in code that's not checked in yet.
Mark Baker
I think your work flow is kind of backwards. Check in often.. very often. Work on one small task at a time, continual integration, etc. No task so large that it requires you to physically keep track of what you are doing via TODO's.
Simucal
That doesn't make sense. Research (e.g., the stuff that lead to Mylyn) shows that people switch tasks all the time. They don't get to focus on one thing at a time.
Uri
A: 

Before I do a release, I always check all my TODO's. So no, I don't need any additional visual hints to help me resolve those items.

Also, I hate having additional "decoration" in my code, such as highlighting or underlines, because this changes how I read the code and can cause me to miss bugs or make it slightly more difficult to see control flow by drawing my attention to specific lines.

Nick
+1  A: 

If you're developing in Visual Studio you can view your TODO: list from your IDE in a handy list in a dedicated window. That's what I do. It's a lot better than trying to remember to search for all of the TODOs in your code.

Go to the menu bar and select 'View' > 'Task List'. When the window appears, notice you can select a drop down box that has two options: 'User Tasks' by default and then comments. If you select 'comments', it will list all comments, the location and line number where you have written the comment prefixed with TODO:

You can also configure your IDE to include others like HACK if you want. It's a pretty great feature to have if you want to be able to go back to some piece of code later that you got "working" but need to correct later.

Dan Herbert
There's a similar facility in Eclipse.I'm wondering though about the situation when you are looking at X that calls Y, and may not be aware that there's something in Y that is not finished and can bring down X.
Uri
A: 

Simply, whether it's a todo or anything else, if it's not in the Issue Tracker, it doesn't exist. Use the issue tracker like source code control, as it gives a better higher level view of the project than random comments splattered across source code.

Will Hartung
+2  A: 

I use an extended comment marker ("//#"), which I modify my syntax highlighting rules to highlight, and regularly grep my repository for.

I copied the idea from a coworker 10 years ago ("--#" in Ada), and I've trained myself pretty well to see and act on them. Doing the syntax highlighting in the editor helps, but you have to make it part of your normal workflow, or you'll train yourself to ignore it, no matter how visually distinguishable it is.

KeyserSoze
i like this idea i am going to try it out on my current (small) project
Jon Erickson
A: 

I wrote a script to make TODO: comments appear as warnings when I do a build in my IDE (Xcode). It just takes the output of grep and reformats it so that the IDE identifies it as a warning.

I don't know if it makes me resolve them faster, but it keeps me from releasing a build without at least being aware of them.

benzado