The Art Of Commenting In Programming

Today Let’s Talk About The Art Of Commenting In Programming, I hope You Like This…

Two Viewpoints

We don’t need comments! The code itself should be self-documenting!Comments are very helpful! We should write them as mush as we can!

Two Reactions

Most of the time code can describe How, But it cannot explain Why!You can remove the comments by rewriting the code to be more legible!

Correct Approach

Write code as more readable & legible as you can. And also, Use comments to give readers valuable information which they can’t find in the code!


Readable Code : Best practices

  • Meaningful Identifier Name
  • Consistent Naming Scheme
  • Consistent Indentation
  • Limitation Of Line Length
  • Proper Use Of Whitespace

Types Of Comments

The Good

/*
We had to write this function because of
the browser interprets that everything is a box.
*/
function manipulate() {
......
}

The Bad

//Fetches the data and stores it in a variable
let a = b();

The Ugly

// Calculate Annual Expenses
let amount = annualIncome();

Its Your Turn! How Do You Comment Your Code?

Like
Like Love Haha Wow Sad Angry
Sachin Sharma

Sachin Sharma

I am a programmer and Tech Enthusiast who loves to use my creative skills to solve complex problems.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *