Adding TODOs to your C# code

Havings TODO items in your code is inevitable. I have yet to see a project where we do not have to come back and alter a few things later. In my recent project where I had to write an integration module to a financial transactions settlement system which was not totally ready. That settlement system was accessible to me through web services but a lot of those web services were not just ready yet. I had to write a log of code assuming that certain methods with those parameter will be available to me some day and hence the use of TODO markers. Visual Studio makes it very convenient. It has a few keywords like TODO, HACK or UNDONE which can be prepended to a comment to make it special.

For example a comment like:

// TODO: this needs to be done
// MySystem.Method1(parameters);

Once you have a comment like this in your code it becomes a part of your task list. The task list can be viewed anytime through the menu View -> Task List. The task list will be displayed by default along with the error list. The task list window has its own little drop down menu having its own options, User tasks or Comments. Select the comments option and all TODO, HACK or any other special comment you have in your code will be displayed there. It is a perfect way to create reminders about what still needs to be done in your code so you don’t miss out anything by mistake.

And yes, you can create your own keywords as well. This MSDN article (http://msdn.microsoft.com/en-us/library/zce12xx2(v=vs.80).aspx) shows how to do that.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s