1179
Comenting code (lemmy.ml)
you are viewing a single comment's thread
view the rest of the comments
[-] jonathanvmv8f@lemm.ee 24 points 5 days ago* (last edited 5 days ago)

Asking as a newbie programmer: how do you suggest we write comments that explain the 'why' part of the code? I understand writing comments explaining the 'what' part makes them redundant, but I feel like writing it the former way isn't adding much help either. I mean, if I created code for a clock, is writing "It helps tell what time it is" better than writing "It is a clock" ?

It would really help if someone could give a code snippet that clearly demonstrates how commenting the 'correct' way is clearly better than the way we are used to.

[-] firelizzard@programming.dev 4 points 4 days ago

My comment game has gotten far better since I started doing live code reviews. Essentially I ask myself, “Would I feel the need to explain this to someone during a code review?” and if the answer is yes I add a comment.

load more comments (24 replies)
this post was submitted on 28 Sep 2024
1179 points (99.2% liked)

Programmer Humor

32162 readers
588 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS