Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Comment the why, not the what.


It's good to comment the what too if it's hard to discern what it's doing from the code.

There have been a number of cases where, for instance, I had to call a bizarrely named API and do something unexpected in order to get an unintuitive outcome and in that case a "what" comment isn't such a bad idea.


Comment the intentions and motivations for behavior.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: