DEV Community

Discussion on: "Do not comment on your code, it should be self-documented". Well... I don't agree.

Collapse
 
codbugs profile image
Coding Bugs

Having read almost all the comments, there are none that indicate how the content of the comments should be as it is the most important thing.

In my case, I try to avoid commenting whenever I can to force myself to make the code readable by itself. This way, I make sure that any colleague and even myself are able to understand the reason for that lines of code.

Comments are useful when explaining the reasons for the code and not telling what it does or does not do. For example, if you have followed the "Proxy" pattern, it is convenient to explain what each of the classes represents and the reason for creating them.