5 Toxic Code Comment Types Every Developer Should Eliminate
This article explains five common types of programming comments that hinder readability—such as self‑promoting tags, outdated code blocks, redundant explanations, irrelevant stories, and lingering TODOs—and offers practical advice on how to avoid them.
Have you ever received code review comments that seemed unnecessary? Good comments improve readability, but some types are counterproductive.
1. The Show‑off Programmer
public class Program
{
static void Main(string[] args)
{
string message = "Hello World!"; // 07/24/2010 Bob
Console.WriteLine(message); // 07/24/2010 Bob
message = "I am so proud of this code!"; // 07/24/2010 Bob
Console.WriteLine(message); // 07/24/2010 Bob
}
}This programmer stamps every line with his name and date, thinking it’s impressive. Version control already tracks authorship, so such inline tags are redundant.
2. The Outdated Programmer
public class Program
{
static void Main(string[] args)
{
/* This block of code is no longer needed
* because we found out that Y2K was a hoax
* and our systems did not roll over to 1/1/1900 */
//DateTime today = DateTime.Today;
//if (today == new DateTime(1900, 1, 1))
//{
// today = today.AddYears(100);
// string message = "The date has been fixed for Y2K.";
// Console.WriteLine(message);
//}
}
}If code is obsolete, delete it instead of commenting it out. Version control lets you retrieve old versions if needed.
3. The Redundant Programmer
public class Program
{
static void Main(string[] args)
{
/* This is a for loop that prints the
* words "I Rule!" to the console screen
* 1 million times, each on its own line.
* It accomplishes this by starting at 0 and
* incrementing by 1. If the value of the
* counter equals 1 million the for loop
* stops executing. */
for (int i = 0; i < 1000000; i++)
{
Console.WriteLine("I Rule!");
}
}
}Basic logic need not be explained in comments; doing so wastes space and time.
4. The Story‑telling Programmer
public class Program
{
static void Main(string[] args)
{
/* I discussed with Jim from Sales over coffee
* at the Starbucks on main street one day and he
* told me that Sales Reps receive commission
* based upon the following structure.
* Friday: 25%
* Wednesday: 15%
* All Other Days: 5%
* Did I mention that I ordered the Caramel Latte with
* a double shot of Espresso?
*/
double price = 5.00;
double commissionRate;
double commission;
if (DateTime.Today.DayOfWeek == DayOfWeek.Friday)
{
commissionRate = .25;
}
else if (DateTime.Today.DayOfWeek == DayOfWeek.Wednesday)
{
commissionRate = .15;
}
else
{
commissionRate = .05;
}
commission = price * commissionRate;
}
}When a comment mentions people or unrelated facts, it becomes noise; future readers may not know who “Jim” is.
5. The “Do It Later” Programmer
public class Program
{
static void Main(string[] args)
{
//TODO: I need to fix this someday - 07/24/1995 Bob
/* I know this error message is hard coded and
* I am relying on a Contains function, but
* someday I will make this code print a
* meaningful error message and exit gracefully.
* I just don't have the time right now.
*/
string message = "An error has occurred";
if(message.Contains("error"))
{
throw new Exception(message);
}
}
}TODO comments are useful early in development, but they should be resolved promptly; otherwise they accumulate technical debt.
To avoid these pitfalls, follow best‑practice guidelines such as those in Steve McConnell’s Code Complete .
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
21CTO
21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
