Blank Yellow Sticky Note

TODOs do not belong in the source code they get lost and forgotten. I was recently reminded of this when I had gone through some code to remove some code quality issues, that when resolved revealed that there was a to do in the comments of the code that had been there for two years!

Example
// TODO: Uncomment this and get rid of below code when Mike H. checks in code moving extension
// utilities to Aclara.iiDEAS.Common.Util 
// TODO: Remove
var dt = DateTime.UtcNow;
var delta = dt.Ticks % TimeSpan.FromMinutes(15).Ticks;
var toDate = new DateTime(dt.Ticks – delta, DateTimeKind.Utc);
// TODO: End Remove

The only time that this will be caught is the when the next person comes to this area of the code and reads it, by that time the context as to why this was put in place is lost and based on the example above confusing. Do we remove the code between the two TODOs, what code is commented out that needs to be uncommented?

If you have an area of code that needs a TODO that you will not be able to get to, instead of creating a TODO comment create the task in TFS. When creating the ticket add enough information so that a consultant you hire 5 years down the road knows exactly what to do.

Categories: Code Quality