Don’t forget to remove temporary code. Comment tokens helps you
Earlier today Joost van Schaik(@LocalJoost) tweeted about piece of temporary code he forgot to remove which caused performance degradation.
Just solved a performance problem by removing a Thread.Sleep(10000) I put in to test the wait animation - and totally forgot about #oops LOL—
Joost van Schaik (@LocalJoost) October 15, 2012
I think Joost is not the only one who forgot piece of code somewhere and didn’t realize it is causing the problem. I was/am not the exception, but I found way how to avoid it. My solution for this problem is named Comment tokens which helps me a lot when I am not lazy to use it.
Comment tokens are words used at the very beginning of the comment and indicates that the comment might be visible in the Task List, if you set them correctly in your Visual Studio. Let’s take a look how it works.
Investigating comment tokens
Open the Task List window using Ctrl + W, T shortcut or navigating thru top menu opening VIEW and then clicking Task List.
Task List windows will appear in the bottom of the Visual Studio user interface. Don’t be confused when nothing appears after you’ve opened it. User Tasks are selected as a default. You need to select Comments option in the dropdown list.
But nothing is there still. Yeah, I’ve forgot we need to create some comment with token. So, let’s move to Visual Studio settings and take a look at the defaults. Through VS top menu navigate to the Options in the TOOLS dropdown menu.
Dialog with Visual Studio options will appears. Click Task List item.
On the right side of the dialog windows you can see the option for setting up the Task List, but we’ll focus on the Token section. Here are Visual Studio defaults we can use immediately.
So, Let’s try it out with default tokens. I’ve used three of them in the code. Watch the Task List window where you can spot all of them now. When you take a look at right side of the Task List windows you can see there are informations related to these comments(green outline). It helps you to better understand in which file these comments arw. Another great thing is that you don’t need to use exactly the same case of your tokens. You just need to write the word only.
Hey, did you notice the red exclamation mark left to the unresolvedmergeconflict? You’re guessing right. Comments token can be prioritized. Low(blue down arrow), Normal and High priority(red exclamation mark) available. Higher priority token got, higher it appears in the Task List.
Setting up custom comment tokens
I hope you remember how get into Task List settings, so open it again(Hint: TOOLS > Options > Task List). We’ll set our first custom comment token. I will start with REMOVE token. Select one of the existing tokens(red outline) and change name and priority as you want/need(green outline). After you made change to the token name dialog disables Change and Delete buttons and activates Add button(yellow outline). After you’re done, click that Add button to insert your first custom token into the list.
I made some comment tokens and I’ll show you how to use them, but for now you have to think about it at your own. I am convinced you understand it and next image doesn’t need to be explained anymore.
How to start using Comment token
I don’t want to wrote a lot about it, cause there is really nice article Comment and Tasks in Visual Studio written by Dan Gilleland(@dagilleland) that is good enought to kick start. You can find useful Task List article on MSDN Library.
To avoid forgetting temporary code mark it with inline comment with token. It will help you quickly overview the code without overhead of searching for the problem or creating Task which is planned for later when the pressure allow you to take care of it. For me its better to create inline comment with token then creating new Task in the TFS if I only need to have some pointer to code I wanna review or have marked for any reason.