In the bible of software engineering, Clean Code, comments are often characterized as failures to write expressive code. Unfortunately, the rise of Generative AI has tempted many developers into the lazy habit of asking LLMs to just "add comments" to messy code blocks. This is a step backward. Instead of using AI to generate apologies for bad code, we should use it as a merciless refactoring partner to suggest better naming and function extraction, making comments obsolete.In the bible of software engineering, Clean Code, comments are often characterized as failures to write expressive code. Unfortunately, the rise of Generative AI has tempted many developers into the lazy habit of asking LLMs to just "add comments" to messy code blocks. This is a step backward. Instead of using AI to generate apologies for bad code, we should use it as a merciless refactoring partner to suggest better naming and function extraction, making comments obsolete.

The "Comment" Fallacy: Why Self-Documenting Code is Still the Goal

2025/11/27 13:47
6 min read
For feedback or concerns regarding this content, please contact us at crypto.news@mexc.com

\ Robert C. Martin (Uncle Bob) famously wrote in Clean Code: "Every time you write a comment, you should grimace and feel the failure of your ability to express yourself in code."

It’s a harsh truth that experienced engineers eventually learn: comments lie.

They don't start as lies. They start as helpful little notes. But code is a living, breathing thing. It gets refactored, debugged, and hotfixed. Often, the developer makes the code change in a hurry but forgets to update the comment sitting right above it.

The moment code and comment diverge, the comment becomes a trap. A lying comment is significantly worse than no comment at all because it actively misleads the next person debugging the system.

For years, the industry pushed towards "self-documenting code" - the idea that through descriptive variable names, small single-responsibility functions, and clear architecture, the code should read like prose.

Then, ChatGPT arrived.

\

The "Explain This" Trap

AI has introduced a dangerous new anti-pattern into workflows. It’s incredibly tempting to take a nasty, complex, poorly named block of legacy spaghetti code, paste it into an LLM, and type:

The AI will happily oblige. It will parse the Abstract Syntax Tree and generate grammatically correct English sentences describing the mechanical operations of the code.

You paste it back into your IDE, commit it, and feel productive. You have "documented" the legacy debt.

But you haven't fixed anything.

You have just added noise. You have plastered wallpaper over a cracking wall. You now have messy code plus paragraphs of text that will inevitably drift out of sync with reality.

AI, when used this way, acts as an enabler for bad habits. It reduces the friction of creating low-quality documentation.

\

Shifting the Frame: AI as a Refactoring Architect

If the goal is self-documenting code, we need to stop treating AI as a commentator and start treating it as a senior code reviewer obsessed with readability.

We don't need AI to explain what the code is doing (we can read syntax). We need AI to help us structure the code so the what is obvious, leaving room for humans to document the why (the business context, the weird edge case that forced this specific implementation).

Here is how to change your prompting strategy to achieve clean code.

\

1. The "Naming Engine" Strategy

Naming things is one of the two hardest problems in computer science. When you are deep in implementation details, your brain often defaults to tempVar, dataList, or processStuff().

Instead of commenting a bad name, ask AI to suggest good ones.

Bad Prompt: "Add a comment explaining what the variable d holds."

Good Prompt: "I am using this variable d to store the difference in days between the transaction date and today to determine eligibility for a refund. Suggest 3 descriptive, camelCase names for this variable that would make a comment unnecessary."

AI Output might be:

  • daysSinceTransaction
  • refundEligibilityWindow
  • daysElapsed

Swapping d for daysSinceTransaction instantly removes the need for an explanatory comment.

\

2. The "Extraction Specialist" Strategy

Comments are often used to delimit sections inside a massive, monolithic function. You’ll see things like // ---- VALIDATION LOGIC ---- followed by 20 lines of if statements.

This is a cry for help. The code is begging to be extracted into a function.

Bad Prompt: "Add comments to divide this long function into logical sections."

Good Prompt: "Analyze this 50-line function. It seems to be doing too many things. Identify distinct responsibilities that could be extracted into separate, private functions. Suggest names for those functions and show me the refactored main function."

The AI will identify that lines 10-30 are handling validation and suggest extracting them into a function named validateInputRequest(). The main function becomes cleaner, easier to read, and the comment // validation logic is replaced by an actual function call that says exactly what it does.

\

A Practical Example: Before and After

Let's look at a typical piece of "business logic" that might exist in a codebase.

\

The "Before" Code (Messy)

// Calculates final price function calc(i, u, t) { let p = i.basePrice; // check if user is premium and apply discount if (u.tier === 'gold' || u.tier === 'platinum') { // 15% off for VIPs p = p * 0.85; } // check tax exemption status based on territory code // some territories like 'OR' or 'DE' don't have sales tax on digital goods if (t !== 'OR' && t !== 'DE') { p = p * 1.10; } return p; }

This code is riddled with single-letter variables and comments explaining things that proper naming should handle.

\

The Lazy AI Approach

If you ask AI to "comment this code", you'll get noise:

function calc(i, u, t) { // Function to calculate... let p = i.basePrice; // Initialize price to base price // If user is gold or platinum if (u.tier === 'gold' || u.tier === 'platinum') { // Multiply price by 0.85 p = p * 0.85; } // ... etc

This is useless. It just repeats the code in English.

\

The Clean Code AI Approach

Let's use the prompts described above.

  1. Prompt: "Suggest better names for arguments i, u, and t in the context of a pricing function." -> item, user, territoryCode.
  2. Prompt: "Suggest a better name for variable p." -> currentPrice.
  3. Prompt: "Extract the logic inside the first if statement into a function that determines if a user gets a VIP discount."

The resulting code needs zero comments to be understood.

\

The "After" Code (Self-Documenting)

function calculateFinalPrice(item, user, territoryCode) { let currentPrice = item.basePrice; if (isVipUser(user)) { const VIP_DISCOUNT_MULTIPLIER = 0.85; currentPrice *= VIP_DISCOUNT_MULTIPLIER; } if (isTaxableTerritory(territoryCode)) { const STANDARD_TAX_MULTIPLIER = 1.10; currentPrice *= STANDARD_TAX_MULTIPLIER; } return currentPrice; } // Helper functions (likely private) function isVipUser(user) { return user.tier === 'gold' || user.tier === 'platinum'; } function isTaxableTerritory(territoryCode) { const taxExemptTerritories = ['OR', 'DE']; return !taxExemptTerritories.includes(territoryCode); }

No comments needed. \n The naming, structure, and extracted helpers explain everything.

\

Conclusion

The purpose of code is communication - between humans, across time. You are communicating with your future self and your teammates.

While AI tools are awe-inspiring, we must be vigilant about how we use them. Using AI to generate comments on bad code is like using a high-end label maker to organize a hoard of garbage.

Don't lower the bar just because AI makes it easy to do so. Use AI to raise your standards. Demand that it helps you write code so clean that comments become unnecessary.

\

Market Opportunity
RISE Logo
RISE Price(RISE)
$0.003039
$0.003039$0.003039
-4.61%
USD
RISE (RISE) Live Price Chart
Disclaimer: The articles reposted on this site are sourced from public platforms and are provided for informational purposes only. They do not necessarily reflect the views of MEXC. All rights remain with the original authors. If you believe any content infringes on third-party rights, please contact crypto.news@mexc.com for removal. MEXC makes no guarantees regarding the accuracy, completeness, or timeliness of the content and is not responsible for any actions taken based on the information provided. The content does not constitute financial, legal, or other professional advice, nor should it be considered a recommendation or endorsement by MEXC.

You May Also Like

Is Putnam Global Technology A (PGTAX) a strong mutual fund pick right now?

Is Putnam Global Technology A (PGTAX) a strong mutual fund pick right now?

The post Is Putnam Global Technology A (PGTAX) a strong mutual fund pick right now? appeared on BitcoinEthereumNews.com. On the lookout for a Sector – Tech fund? Starting with Putnam Global Technology A (PGTAX – Free Report) should not be a possibility at this time. PGTAX possesses a Zacks Mutual Fund Rank of 4 (Sell), which is based on various forecasting factors like size, cost, and past performance. Objective We note that PGTAX is a Sector – Tech option, and this area is loaded with many options. Found in a wide number of industries such as semiconductors, software, internet, and networking, tech companies are everywhere. Thus, Sector – Tech mutual funds that invest in technology let investors own a stake in a notoriously volatile sector, but with a much more diversified approach. History of fund/manager Putnam Funds is based in Canton, MA, and is the manager of PGTAX. The Putnam Global Technology A made its debut in January of 2009 and PGTAX has managed to accumulate roughly $650.01 million in assets, as of the most recently available information. The fund is currently managed by Di Yao who has been in charge of the fund since December of 2012. Performance Obviously, what investors are looking for in these funds is strong performance relative to their peers. PGTAX has a 5-year annualized total return of 14.46%, and is in the middle third among its category peers. But if you are looking for a shorter time frame, it is also worth looking at its 3-year annualized total return of 27.02%, which places it in the middle third during this time-frame. It is important to note that the product’s returns may not reflect all its expenses. Any fees not reflected would lower the returns. Total returns do not reflect the fund’s [%] sale charge. If sales charges were included, total returns would have been lower. When looking at a fund’s performance, it…
Share
BitcoinEthereumNews2025/09/18 04:05
Pro Global Scales Latin American Hub as Hybrid Model Accelerates Latin America Growth

Pro Global Scales Latin American Hub as Hybrid Model Accelerates Latin America Growth

Pro Global is accelerating its expansion in Latin America, with investment in its regional head office in Argentina as both international and domestic carriers
Share
ffnews2026/03/23 08:00
Tokenized deposits push Europe toward next-gen digital money

Tokenized deposits push Europe toward next-gen digital money

The post Tokenized deposits push Europe toward next-gen digital money appeared on BitcoinEthereumNews.com. As banks rewire payments and settlement systems, tokenized
Share
BitcoinEthereumNews2026/03/23 18:29