,

“Consider refraining from adding comments to your code” 🚫 #coding #codingtips #reactjs

Posted by

Why You Shouldn’t Add Comments to Your Code

You Shouldn’t be Adding Comments to Your Code 😤

When it comes to coding, many developers have differing opinions on whether or not comments should be added to their code. Some argue that comments are essential for understanding the purpose of certain code snippets, while others believe that well-written code should be self-explanatory.

However, there are several reasons why you shouldn’t be adding comments to your code:

  • Comments can become outdated: When code is updated or refactored, comments are often left behind and can become misleading or inaccurate.
  • Comments can be redundant: If the code itself is clear and well-written, comments can be unnecessary and clutter the codebase.
  • Comments can be a crutch: Relying on comments to explain code can hinder a developer’s ability to write clean and understandable code.

Instead of adding comments to your code, consider following these coding best practices:

  1. Write clear and descriptive variable and function names: Using meaningful names for your variables and functions can eliminate the need for comments.
  2. Break down complex code into smaller, more manageable chunks: By breaking down complex code into smaller functions or modules, you can make your code more readable and easier to understand.
  3. Use consistent formatting and indentation: Consistent formatting can make your code more visually appealing and easier to follow.

Ultimately, the goal of writing code should be to create a clear and understandable product. By focusing on writing clean and self-explanatory code, you can avoid the need for comments altogether.

#coding #codingtips #reactjs

0 0 votes
Article Rating
5 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@ItsYaBoiStigzz
10 months ago

Rice

@FarazMazhar
10 months ago

Funny story. A few years ago, I was asked to create a Python script to generate some report on the available data. Since I wasn't provided with any formal task or repository, I thought we were just doing a POC so I named my dataframe "very_cool_df". Anyways, a few days later, I got an email from the Solution Architect saying that the client faced some error and forwarded me the stack trace. Literally the first line said that something went wrong with "very_cool_df". I was honestly dying from cringe so I quickly properly formatted and named everything before sending emailing him back the fixed version. Lesson learned, now I properly name and format everything even if it's something that's not going leave my machine.

@nightwalker-ym3sh
10 months ago

Comment 🤔

@EricEGunes
10 months ago

All of them are tools to connect through timeline with other engineers 🤷🏼‍♂️ use them all !!

@soumyaripan5131
10 months ago

Yes, exactly what I do. Your naming of variables n functions should be meaningful so you will need lesser comments and more clean code.