Visual Studio TODO, HACK and your Task List


In the last couple of weeks I’ve made great use of the TODO and HACK task tokens in Visual Studio to track work-arounds and changes that have been made in our project. We’re running parallel with the existing system in a test state and there are lots of little changes that the users want (default sort orders and filters, changes to headings and calculations to include sub-totals) which need to be replicated through out the system besides the module in which the user spotted the problem.

Because time isn’t immediately available to work on keeping the modules consistent, the team has started using TODO and HACK comments where the changes need to be made. Then at least everyone can see what’s going on and what’s still outstanding. (I don’t know if these pull through into the greater scheme of things like documents in Visual Studio Team System, but that would be really cool).

Adding a TODO or HACK is as simple as commenting:

VB.NET
‘ TODO fix this problem here

C#
// TODO fix this problem here

And opening your Task List in Visual Studio. I have mine docked under my Properties window so it’s always available.

One note to point out is that Visual Studio displays tasks differently for Visual Basic .NET and C#.

“With Visual Basic projects, the Task List displays all of the comments in the project. With Visual C# and Visual J# projects, the Task List displays only the comments that are found in the files currently opened for edit. With Visual C++ projects, the Task List displays only the comments that are found in the file currently active in the editor.” - MSDN Library (It really grinds me that the VS IDE doesn’t treat all languages equally)

There’s no documentation about when to use TODO and when to use HACK (there’s also an UNDONE task token and you can create your own); we use HACK if we’ve had to comment a chunk of code out because it breaks or if we’ve inserted a hard-coded value instead of a variable or enumerator. We use TODO when fresh code needs to be inserted.

Information and Links

Join the fray by commenting, tracking what others have to say, or linking to it from your blog.


Other Posts
Dev.Mag Issue #9 and Comp 12
Get the latest Dev.Mag issues

Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.

Reader Comments

Be the first to leave a comment!