3 ms·
To you as the author it might be crystal clear, but the next person who has to modify might not have the full context. A lot of good comments in this thread men
by ck45 5y ago
To you as the author it might be crystal clear, but the next person who has to modify might not have the full context. A lot of good comments in this thread mention that you should write comment about intention (“why”), not implementation details (“how”), although also the latter might make a significant difference to the next person.
And even if your original code might have been clear to another person, it might have been modified in the meantime.
- DrBazza 5y ago> A lot of good comments in this thread mention that you should write comment about intention (“why”), not implementation details (“how”) Erm, that's what I said above. I don't believe that's controversial. And neither is the fact that if there's a 30 line comment above a 100 line function, perhaps the function should be reduced in size because it's clearly complex. In fact, IDEs such as Intellij will flag it for complexity Commenting for the sake of it, especially due to poorly named functions and variables is a code smell. Code is for the reader. The compiler doesn't care if your variables are two characters or twenty.
- ziml77 5y agoBreaking up a function doesn't always make it easier to follow. Instead it sends you bouncing around, trying to keep track of all the values passed back and forth. Some things you need to do are just complex because there's lot of complex rules and mathematics.