r/learnprogramming • • Mar 22 '22

Don't be that guy.

I just took over a project for a guy who left. Don't be this guy:

  • ZERO comments in your codebase.

  • One and two character variable names with no discernable pattern.

  • Comment characters used to comment out big chunks of code for no discernable reason.

  • No error checking.

  • Reliance on data files that you forgot to include or explain, going in to meaningless data frame names.

  • Making outrageous claims about how much your code improves things with zero baseline performance.

People like this think you're an idiot because you can't make their code work, and get to be all smug. We will track you down and find you. You will need references someday....oh my.

2.6k Upvotes

427 comments sorted by

View all comments

1

u/IdempodentFlux Mar 22 '22

Do you think comments are needed if the function names are super clear/read like a sentence?

3

u/[deleted] Mar 22 '22

Overcommenting is a beginner's mistake that can reduce code legibility. I often see beginners write x = x + n; // add n to x. Comments should be used sparingly to explain how code should be interpreted and what it needs, and the code should itself be legible. Add as many comments as it takes for someone who can read code to understand your code, and not more. So, yes, if the function is short and tidy and does not have secret side-effects or byzantine demands, you can do without comments.

→ More replies (4)