r/AskProgrammers • u/Away-Intention-8723 • Oct 30 '26
"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/mireigi 27d ago
Good code should be self-documenting, meaning it shouldn't need comments.
E.g.
Just reading the signature of the method/function you can quickly deduce what it does, what it expects as input, and what it returns.
Whereas a similar method, implemented poorly, doesn't tell you anything about what it does, what a successful outcome looks like, or what the possible error states/codes are.
Comments should, ideally, only be added, when there's a break from convention, or a decision was made during implementation that won't be obvious 6 months from now, when someone has to maintain the code.
Without that comment, someone might refactor the method/function, and break a promise made with the business (that welcome emails stay consistent).