DEV Community

Rajesh Dhiman
Rajesh Dhiman

Posted on • Originally published at rajeshdhiman.in on

Why Code Comments Are Important?

Do you write comments in your code? If you do, that’s awesome, and if you don’t, start adding comments right away. I couldn’t do it all until the code was straightforward boilerplate code or some standard stuff that you write every day. But if it is a complex logic, some condition or group of conditions, then it takes a lot

Read More

The post Why Code Comments Are Important? appeared first on Rajesh Dhiman.

Top comments (4)

Collapse
 
chri3gabrielsson profile image
chri3gabrielsson

I disagree wholeheartedly with the fact that complex code should be commented on. Comments in code should only be used for why something was done not what it is or how it works. The what and how should be obvious from the code. If it's so complex that a function needs a comment then it either needs to be refactored or redone. The two principles that should always be followed is: Code should be ETC(Easy to Change) and DRY(Don't repeat yourself). Code that is commented is rarely both of those and excessive code comments violate both of the principles

Collapse
 
kwameaj67 profile image
Kwame Agyenim-Boateng

Comments make code readablility easy and understandable

Collapse
 
mcsee profile image
Maxi Contieri

only if you write not declarative code

Collapse
 
mcsee profile image
Maxi Contieri