1193
Comenting code (lemmy.ml)
you are viewing a single comment's thread
view the rest of the comments
[-] jonathanvmv8f@lemm.ee 24 points 2 weeks ago* (last edited 2 weeks 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.

[-] zeekaran@sopuli.xyz -1 points 2 weeks ago

Unless you're writing something in the open source world, rarely does any code need comments at all.

[-] firelizzard@programming.dev 5 points 2 weeks ago

That’s a hot take. If you want your code to be maintainable at all, it needs comments. If you’re part of a team, write comments for them. If someone else may take over your project after you move on, leave comments for them. And have you ever tried to read uncommented code you wrote a year ago? Leave comments for yourself.

load more comments (23 replies)
this post was submitted on 28 Sep 2024
1193 points (99.0% liked)

Programmer Humor

32266 readers
60 users here now

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

Rules:

founded 5 years ago
MODERATORS