TODO Formatting
Posted
by charlie.mott
on Geeks with Blogs
See other posts from Geeks with Blogs
or by charlie.mott
Published on Tue, 22 Nov 2011 19:29:25 GMT
Indexed on
2011/11/23
1:54 UTC
Read the original article
Hit count: 280
Article Source: http://geekswithblogs.net/charliemott
TODO's should only be used for a short period of time to remind you that something needs to be done. They should then be addressed as soon as possible.
In order to know who owns a TODO task and how long it’s been outstanding, my company uses the following standard for TODO formatting:
Format: // TODO : Owner Initials – Date Created – Description of task.
Sample: // TODO: CM – 2012/01/20 – Move this class to a new location so it can be reused.
Using this pattern makes it easy to use the Resharper TODO explorer.
The Carrot
In order to make it easy for developers to apply this rule, a code snippet can be created in Visual Studio. Even better, I created a Resharper template. This gives the facility to use the current user name and current date macros.
image
This actually makes the formatting look like this.
Sample: // TODO: cmott – 2012/01/20 – Move this class to a new location so it can be reused.
The Stick
How to you enforce such a rule?
I tried to create a custom Resharper Highlighting Pattern to perform custom code analysis inspection for deviations from this pattern. However, I did not have any success. The find dialog would not accept // text. If I work it out, I will update this blog post.
StyleCop
Instead I created a custom StyleCop rule. I followed the approach used with the StyleCop Contrib project. This provides a simple to use base class and easy to use unit testing framework. I will upload this todo format analyzer as a patch to that project.
image
© Geeks with Blogs or respective owner