DEV Community

Discussion on: Clean Code Applied to JavaScript — Part IV. Comments

Collapse
 
thomasjunkos profile image
Thomas Junkツ

Absolutely this.

I would rephrase

Only comment things that have business logic complexity

to

Comment non obvious decisions

Because there may be cases where

  • you have (mathematical) knowledge which the future reader of your code might not have

  • your code isn't correct but a smart approximation which is good for now

  • your code isn't correct and no approximation to anything but for reasons outside the code it is written like that. I actually did this where data was sometimes deliberately overwritten with null which was wanted behaviour. So I commented this as

    //Customer decision: do this and that else null the value

And when a furture reader stumbles over this line of code he saves time not discussing this point any further