Code Smell 05 - Comment Abusers

Code Smell 05 - Comment Abusers

Leader posted 6 min read

The code has lots of comments. Comments are coupled to implementation and hardly maintained.

TL;DR: Leave comments just for important design decisions. Don't explain the obvious.

Problems

  • Maintainability

  • Obsolete Documentation

  • Readability

  • Duplication between code and comments

Solutions

1) Refactor methods.

2) Rename methods with more declarative names.

3) Break down large methods.

4) If a comment describes what a method does, name the method with this description.

5) Just comment on important design decisions.

https://maximilianocontieri.com/what-exactly-is-a-name-part-i-the-quest

Refactorings ⚙️

https://maximilianocontieri.com/refactoring-005-replace-comment-with-function-name

https://maximilianocontieri.com/refactoring-011-replace-comments-with-tests

https://maximilianocontieri.com/refactoring-002-extract-method

Examples

  • Libraries

  • Class Comments

  • Method Comments

Context

You write comments when you feel your code does not speak by itself.

Most of the time, you add noise instead of clarity.

Later, those comments lie when you change the code but forget to update the explanation.

Instead of helping, they hurt.

Sample Code

Wrong

<?

final class ChatBotConnectionHelper {
    // ChatBotConnectionHelper is used
    // to create connection strings to Bot Platform
    // Use this class with getString() function
    // to get connection string to platform

    function getString() {
        // Get Connection String from Chatbot
    }
}
<?

final class ChatBotConnectionSequenceGenerator {

    function connectionSequence() {
    }
}

Detection

[X] Semi-Automatic

Linters can detect comments and check the ratio of comments to lines of code against a predefined threshold.

Tags ️

  • Comments

Level

[X] Beginner

Why the Bijection Is Important ️

Your software should reflect the domain with no translators in between.

When you use comments as crutches, you break the one-to-one mapping between the real-world concept and its code representation.

This mismatch creates confusion and bugs.

AI Generation

AI tools often generate comments to explain code in natural language.

This can pollute your source when the code already speaks for itself.

AI Detection

AI tools can easily remove redundant comments and suggest clearer names.

You only need to instruct them to "remove obvious comments and refactor for clarity."

Try Them!

Remember: AI Assistants make lots of mistakes

Suggested Prompt: correct=Remove all Comments

Without Proper Instructions With Specific Instructions
ChatGPT ChatGPT
Claude Claude
Perplexity Perplexity
Copilot Copilot
You You
Gemini Gemini
DeepSeek DeepSeek
Meta AI Meta AI
Grok Grok
Qwen Qwen

Conclusion

Leave comments just for important design decisions. Don't comment on a method with a bad name, rename it.

Relations ❤️

https://maximilianocontieri.com/code-smell-75-comments-inside-a-method

https://maximilianocontieri.com/code-smell-57-versioned-functions

https://maximilianocontieri.com/code-smell-168-undocumented-decisions

https://maximilianocontieri.com/code-smell-151-commented-code

https://maximilianocontieri.com/code-smell-183-obsolete-comments

https://maximilianocontieri.com/code-smell-146-getter-comments

More Information

https://refactoring.guru/es/smells/comments

https://maximilianocontieri.com/what-exactly-is-a-name-part-i-the-quest

https://dev.to/alexbunardzic/code-comments-are-a-sign-that-something-s-off-19e1

https://arter.dev/how-to-comment-your-code-like-a-boss

Credits

Photo by Volodymyr Hryshchenko on Unsplash


If you have to spend effort looking at a fragment of code and figuring out what it’s doing, then you should extract it into a function and name the function after the what.

Martin Fowler

https://maximilianocontieri.com/software-engineering-great-quotes


This article is part of the CodeSmell Series.

https://maximilianocontieri.com/how-to-find-the-stinky-parts-of-your-code

1 Comment

0 votes

More Posts

Code Smell 04 - String Abusers

Maxi Contieri - Nov 28, 2025

Code Smell 319 - Hardcoded Stateless Properties

Maxi Contieri - Apr 9

Code Smell 17 - Global Functions

Maxi Contieri - Feb 28

Code Smell 16 - Ripple Effect

Maxi Contieri - Feb 19

Code Smell 15 - Missed Preconditions

Maxi Contieri - Jan 30
chevron_left

Related Jobs

View all jobs →

Commenters (This Week)

1 comment
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!