What are the benefits of using comments

coding-styleprogramming practicesprogramming-languages

I just accepted a new job. Our application is in the 50,000 lines of code area. None of which is commented. I am finding it difficult to understand how the application works. Id like to prevent this for the next person that joins the project by getting the team to start to use comments.

Forget about if you support comments or consider them code duplication. What are some of the benefits of using comments that I can use as reasons for the team to start using them. What arguments are there in favor of comments (Not looking for opposing arguments). Are there any publications or studies done that show that using comments improves code quality or something like that?

Best Answer

Clean Code has a whole chapter on comments, when they're good and when they're not. Also a lot of practical advice on how to write code that doesn't need so many comments.

Edit: Anna asked for a summary, and since you were asking only for pro-comment reasons, the table of contents level summary of good reasons to use comments from the book includes:

  • Legal notices, like copyrights
  • When you can't use a function name to explain something
  • Your intent behind a decision
  • Clarification of code you can't alter, like library call results
  • Warning of consequences
  • TODOs (to a reasonable degree)
  • Amplify the importance of something seemingly inconsequential
  • Javadocs in public APIs

There's a couple paragraphs or more on each of those topics, with actual code samples included for illustration. It really is a worthwhile read.