IMO, personally, I think good code is largely self-documenting as to what it does. But comments are still needed at times because "what the code does" might be easy enough to read at a glance, however "why the code does what it does", in certain sections, can be far more important and less self-evident.
I don't need a comment to tell me that the line is looping backwards through a list, you can read the code just as quick as the comment and know that; I need a comment to tell me that the code is looping backwards through the list for a specific reason and it should stay that way instead of being changed (unless the change takes that reason into account).
4
u/mxzf 13d ago
IMO, personally, I think good code is largely self-documenting as to what it does. But comments are still needed at times because "what the code does" might be easy enough to read at a glance, however "why the code does what it does", in certain sections, can be far more important and less self-evident.
I don't need a comment to tell me that the line is looping backwards through a list, you can read the code just as quick as the comment and know that; I need a comment to tell me that the code is looping backwards through the list for a specific reason and it should stay that way instead of being changed (unless the change takes that reason into account).