Re:A Short Cautionary Tale About Refactoring
by rawoke083600 on Sunday March 21, 2021 @04:35AM
(#26528999)
Yea, there are many schools of thought on what/how to comment "properly". But I have found this simple rule to cover most of the cases, it's not perfect but better than most:
"The code is the HOW, the comments are the WHY"
Re:A Short Cautionary Tale About Refactoring
by TeMPOraL on Sunday March 21, 2021 @06:16AM
(#26529385)
That's a good rule of thumb. Personally, I also add comments for the HOWs that may be relevant to users of a function/class, that cannot be easily expressed in code in the function signature or class declaration.
Things like, "relative ordering of results is not preserved", or "this function is O(n^3)".
In other words, it could/needed still to be improved for better maintainability, not just in the obvious way (Chesterton's fence, as mentioned by another commenter)