Fuck, I’ll look at code I wrote like a month ago and be like, “what was I thinking?”. So I try to fix it, run into some stupid issue and be like, “oh, right.”
And this is why comments are useful on code who’s purpose or reasoning isn’t super obvious or even looks counter intuitive.
A professor used to say, we don’t write code for the machine. The machine doesn’t need code. It would be just as happy whether we hand carve 1s and 0s on ferromagnetic disks or if we wrote a compiler for emojis. Binary is binary. We write code for the humans. So make it legible.
I never said anything about comments. My professor advocated that the code should tell yourself and other humans what it was making the machine do. Comments should document the design and the architecture. Not explain the code. A well designed and correct code needs few comments.
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmerhumor@lemmy.ml
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
Posts must be relevant to programming, programmers, or computer science.
No NSFW content.
Jokes must be in good taste. No hate speech, bigotry, etc.
Opening a repository for the first time in months.
Which brainless moron wrote this idiotic code?
Runs blame.
Oh, it was me.
No one is a real programmer until they’ve experienced that sensation.
It was more fun before blame, because sometimes it would take 10 minutes to figure out you’re the dumbass.
Fuck, I’ll look at code I wrote like a month ago and be like, “what was I thinking?”. So I try to fix it, run into some stupid issue and be like, “oh, right.”
And this is why comments are useful on code who’s purpose or reasoning isn’t super obvious or even looks counter intuitive.
A professor used to say, we don’t write code for the machine. The machine doesn’t need code. It would be just as happy whether we hand carve 1s and 0s on ferromagnetic disks or if we wrote a compiler for emojis. Binary is binary. We write code for the humans. So make it legible.
But at the same time you can over comment. If your variables are self described it’s not needed.
I never said anything about comments. My professor advocated that the code should tell yourself and other humans what it was making the machine do. Comments should document the design and the architecture. Not explain the code. A well designed and correct code needs few comments.