Join Nostr
2026-11-14 14:39:20 UTC
in reply to

mathew on Nostr: I’m in the “comment heavy” camp too. Any function that is public should have ...

I’m in the “comment heavy” camp too. Any function that is public should have documentation comments, for example.

It’s popular to say that you shouldn’t add comments to say what code is doing, but I think that’s wrong. It’s faster to read through comments like pseudo-code than to decode what the code is doing. More importantly, if you notice the code doesn’t match the comments that’s a clue about a possible defect. The people who complain about these kinds of higher level comments say it adds work to keep them up to date, but in my experience that flows from a desire not to comment anything at all.

You can, of course, overdo it, but I see nothing wrong with “two line comment, 15 lines of code that do that thing, one line comment, 10 lines of code to do it”, and so on.

And of course, commenting *why* is even better.