re: Can you share your favorite quote or rule related to IT? VIEW POST

re: What are your views on this quote?

Well, at first it sounded to me like a very hard and a bit dumb statement. But then, after discussing with this guy, I realized it was quite convincing. The question beneath this statement, is: "Why would you need to comment?". In general, if you can say something directly and clearly in the code, you don't need to comment it.
Let's take a very simple example:

// logs the user
const x = user => {
    // ...

In this example, I think we all agree that the comment is completely useless since we could just make the name of the function more explicit. Then the comment would disappear. So it seems like an implicit rule, that when you can say something in an explicit way in the code, you do it in the code, instead of adding a comment.
Which takes us back to the first statement. Every comment in the code is a confession of failure. The guy told me "Sometimes you need to comment. It happens that you don't have the choice. But then it's a confession of failure, because you couldn't make the code clear enough to be readable and understandable without comments".

I think it's debatable when you take in account the rule "Always comment why and not how", but it's still very relevant in most cases.

I almost never write comments in my code, because everytime I want to, I ask myself first "Is there a way to make my code understandable without comments?".

Code of Conduct Report abuse