4 ms·
Because comments can get outdated and developers don't bother to sync them with their code. The best compromise is to make your code readable and only comment
by arvinsim 9y ago
Because comments can get outdated and developers don't bother to sync them with their code.
The best compromise is to make your code readable and only comment about the "why", not the "how".
- oldandtired 9y agoMaking code readable is only part of the reason for comments. The other part is why the code is there and the history of why certain decisions were made. Without this information, changes to the code can have ongoing subtle and not so subtle ramifications.
- sclangdon 9y agoThat isn't a compramise, it's the goal. Your comments should be about the "why", and not the "how". We already know how, that's what code is - instructions about how something works. What we don't know is why it was done in the first place, or why it was done a particular way, or why I shouldn't change that line that looks wrong but is really correct.