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

26

u/OddBet475 Mar 22 '22

Comments are an absolute last resort. Don't be the opposite and comment the death out of your code. It should be understood without.

There's a place for comments (maybe) but that should be extremely rare. Use meaningful naming, the KISS and do not repeat yourself principles and we can all live without comments. I work in a 25 odd year old code base and comments hurt more then they help, they can't be trusted and may be misleading. People don't fix comments when changing code.

4

u/__Mauroo__ Mar 22 '22

I'm new to programming so i have a question. Isn't writing a comment before ever function/part of code to explain what it does a good idea if you know someone else will have to look at your code? I think it might take some time, especially if you have already tested that function/part of code and know it works

5

u/[deleted] Mar 22 '22

Write comments whether you want to justify certain “weird” choices or if you want to explain a particular complex business logic procedure.