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

I caused a bit of an "incident" at a web dev company I worked at many many years ago by removing commit access from one of the "technical managers", whose hobby was removing every single comment he could find.

"But the code shouldn't need comments," he'd complain, "it should be obvious what it does otherwise it's just bad code!"

Yes, you dobber, it *is* obvious from the code, the *how* is obvious, but the why and the what might not be. The comments explain what it's doing stuff to and why, and in particular why you'd want that and why it's important. Disk space is free, so in a big long comment just write up what that particular bit of business logic is intended to achieve and what it expects as inputs and outputs.

or, TL;DR "DOCSTRINGS BITCH DO YOU SPEAK IT"



I bet they also pulled out the "but the code will change and then the comments become invalid, or even gasp misleading"?


Absolutely, and could not be convinced that if the code and comments got out of sync then it was likely that the function name would no longer make sense, and that's when we get real trouble.

There were horror stories with that codebase, like index.php was set as the default error handler, started by immediately returning 200 OK before going anywhere near URL dispatching, and then displaying a page that said 404 despite returning 200 if it couldn't find the URL.




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

Search: