I saw many developers who are writing comments/copyright information while writing their codes. These innocent commments seem harmless at the first hand. But I believe that no comments must be written during development phase. Comments must be deferred until the last minute when everything is ready for production. Because:
- Comments decrease the readibility of the source code during development phase. Developer does not need a comment in order to understand his own code. If he needs comments, that means the code is not clean and simple enough. So refactoring and cleaning must be the first action, instead of writing comments. Uncle Bob Martin wrote a good article about clean code.
- During development phase, requirements may change. When requirement changes, the code handling the requirement also changes. If there is a comment for the code, it must also change. As a result, the chained dependency brings extra cost to project development time.
So in general, I believe clean code is more important than adding comments. If a necessity really forces for writing comment, for instance for an API, it may be written. But before adding it, everything must be tried in order to remove the comment from code.
So why most developers write comments to his code?
I believe one of the reason for this is that the developer is aware of the fact that there is something complex in the code and assumes that comments will make everything fine. So comments are mostly written as an excuse to the outcomer for the ugly code.
Another reason is the study resources. Usually developers learn new techs by going over the samples distributed with the technical writings. Most of these writings include comments in every piece of code. So a new java student learning from a book sees comments with every getter/setter method which is not necessary. As a result, he uses the same technique in his own developments and everywhere is covered with comments.