DEV Community

Discussion on: Commenting: where?

 
tandrieu profile image
Thibaut Andrieu

Yeah, this might not be a good example, but I like it so much πŸ˜‚.

Just to says that not everyone is a web developers. When dealing with embed aeronautical computer, scientific processing or legacy industrial application, you don't have Swagger and all the modern fancy stuff. C++ is still not certified for aeronautics (as I know. Maybe now it is), and most of the code is in plain C. This kind of program is about 100 millions lines of codes, you just cannot refactor it.

You have to cope with legacy, and renaming a method or a variable in a several millions line of code monolith is not always possible. So when you had finally understood what this particular part of code is doing, you better comment it for the next poor fool who will get lost there. Comment don't break the code. Renaming does...

It may also be the case on brand new code. If you implement a research paper, either you use the same variables that the one used in paper equations and you end up with meaningless variable like "a", "beta", "mu", etc... so loved by mathematicians, either you try to use good naming but in this case you diverge from original documentation.

I agree, code should be self-documented when possible. But sometime comments is the only solution.