DEV Community


Why Code Comments Are Important?

paharihacker profile image Rajesh Dhiman Originally published at on ・1 min read

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.

Discussion (4)

Editor guide
chri3gabrielsson profile image

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

kwameaj67 profile image
Kwame Agyenim-Boateng

Comments make code readablility easy and understandable

mcsee profile image
Maxi Contieri

only if you write not declarative code

mcsee profile image