I want very little comments in code. Functions should tell me what they do. And tbat's about all I really want.
Then if something is truely odd, then yes tell me what is going on in a comment. But in general there probably should not be comment in a function body.
But you don’t seem to realize. Is that a three in the morning when an ops guy is woken up to fix someone else’s code. They don’t wanna have to sit there for two hours reading through it to figure out why a function does something. At the very least being able to grep through code quickly to find things that otherwise can’t be grepped from raw code. The comments aren’t for you. They are for other people having to maintain your code in different environments.
Why would you read code comments to figure out what the code is doing when you can read the code? Also, you have to read the code anyway to make sure it’s actually doing what the comments say it’s doing, so what is the benefit?
If the code is structured and written well, it’s very easy to understand what it’s doing at a quick glance without any comments at all. It is way quicker to do that then to do it and also balance that with what the comment claimed it does.
Comments are notorious for going out of context quickly and being just flat wrong a lot of the time. There are frameworks developed just to manage this one aspect alone.
I view comments as a liability, because I’ve seen engineers get tripped up time and time again when the comments diverge from the code. If you’re relying on comments at 3am to fix an issue rather than reading the code, I really don’t know what to tell you.
Better than being punched in the nuts when the ops guy reads an incorrect code comment and takes a catastrophic action because the code diverged from the comments and what the comment told him to do was actually the wrong thing to do.
And on what planet is an ops guy actually not verifying the comments against the code anyway? Your only argument is that the ops guy wants to be able to ignore the code and just trust comments, which anyone who has programmed in a production environment knows is a terrible fucking idea.
It’s fairly clear I’m talking to a larper here so I will just leave it at this.
1
u/esaule 23d ago
I want very little comments in code. Functions should tell me what they do. And tbat's about all I really want.
Then if something is truely odd, then yes tell me what is going on in a comment. But in general there probably should not be comment in a function body.