10 Commenting Mistakes Developers Hate (And How to Fix Them)
The article examines common problematic comment styles—such as embedding contact info, design details, "how" instead of "why", usage instructions, and algorithm explanations—and suggests modern Git‑based practices to keep code clean and maintainable.
As programmers, we constantly encounter a wide variety of code comments, many of which hinder readability and maintenance.
1. Comments that contain contact information, TODO items, or requirement links
This style shows outdated habits; modern practice is to place such information in Git commit messages, issue trackers, or pull‑request descriptions. The examples below illustrate why these comments should be removed.
2. Comments that embed partial design documentation
These comments are problematic because their accuracy and completeness are uncertain, and they clutter the code. A better approach is to keep design docs in dedicated platforms such as GitHub Pages.
3. Comments that explain how instead of why
Explaining implementation details without the rationale is considered a bad practice. The following screenshot shows a typical "how" comment that should be avoided.
4. Comments that describe method usage, parameters, and possible exceptions
Rather than writing extensive usage comments, it is more effective to provide comprehensive test cases that demonstrate correct usage.
5. Comments that give special algorithmic explanations
These notes can be useful but should be managed together with the code, for example in Git commit logs, to avoid drift between code and comment.
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.
Huawei Cloud Developer Alliance
The Huawei Cloud Developer Alliance creates a tech sharing platform for developers and partners, gathering Huawei Cloud product knowledge, event updates, expert talks, and more. Together we continuously innovate to build the cloud foundation of an intelligent world.
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.
