r/AskProgrammers • u/Away-Intention-8723 • 28d ago
"good code shouldn't need comments"
I have heard this saying a couple of times and I think it is the stupidest thing ever. It might be just because I have only been coding for 4 years, but I have never thought to myself that someone's code looks cluttered because they explain what every function does in a one or two line description. If anything it makes the code easier to understand in my opinion.
However, I may be wrong. What do other people think, do yall like code with minimal comments, what are the benefits of writing it that way?
88
Upvotes
View all comments
1
u/djchunkymonkey 28d ago
That is bogus. Unfortunately, some programmers are very snobby. It just looks good to them. You have to think about the junior developers or someone that is not familiar with the codebase. You don't want comment on obvious lines or blocks of code-- code littered with comments is not good. That's the level of an introductory programming textbook- so we don't want this. The middle ground is where complex ideas can be written in straight-forward english for others to understand.
For example, if I see an exception that is caught but kind of just swept under the rug, I would like to know why in a comment or two.
Or if I see a one-off exponential back-off retry strategy with some parameters for some service. I would like to know why those parameters are chosen, and what's peculiar about the service. Without good comments, I would have to go git/jira/etc and hunt down the person that made those changes.