3 ms·
I try to avoid writing comments as much as possible. Whenever I feel the need to express myself in a comment I ask myself if I can simplify and clarify my code
by pvorb 9y ago
I try to avoid writing comments as much as possible.
Whenever I feel the need to express myself in a comment I ask myself if I can simplify and clarify my code by extracting a method or variable with a descriptive name. In the end every method turns out to be doing only one thing or calling a sequence of other methods.
I only fall back to writing a comment when there's something that can't be expressed in the code itself, e.g. describing another obvious approach that didn't work out.
I also dislike comments that describe every detail about the code. Those tend to mismatch the actual behavior of the code as it gets older.