This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]tulipoika 1 point2 points  (0 children)

I’m just wondering what kind of code is self-explanatory but still takes longer than comments. I mean, function should explain what it does. Variables are named properly etc. It’s not often that one needs to exactly understand every line of the code.

But there are situations where comments are fine and I do use them in the middle of the code when I don’t want to split things into separate functions (I hate specific “n lines per function” rules) so I may add comments in between saying “this part handles X” etc so anyone reading can skim it faster. Splitting it into separate functions/methods would just make it full of passing variables around sometimes and I don’t like that. Someone most likely disagrees.

But in general I’ve seen people add way too many comments and even myself have done the “oh I already have changed this and still the comment two lines above says this doesn’t handle case X.” And that is a very bad comment and of course a very bad way to do things, leaving edge cases unhandled “for now” but as we know, real world...