DEV Community

loading...

Discussion on: To Comment Or Not To Comment?

Collapse
drhyde profile image
David Cantrell

There's the old saw that you should "code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live". That is, don't make him angry by writing really clever code that he can't understand.

Well, comments are part of code. So don't comment in such a way as to piss him off either. So don't assume he's an idiot, that will just annoy him, and don't assume he's really clever and miss out important information that he will need, and for which he will be willing to kneecap your children.

Alternatively, if you find it hard to get into the mindset of a violent psychopath, comment for an audience of yourself on the day you were first exposed to the project you're working on.

Collapse
codemouse92 profile image
Jason C. McDonald Author

Very good way of thinking about it.

Collapse
damindo profile image
Damindo

I comment for (1) the day when I'll come to work with a foggy brain and have to check my code to debug or reverse-benchmark something. (2) that he/she will cover for me

Forem Open with the Forem app