Quote:
Originally Posted by Seta00
People still don't understand what I mean. The space I save using K&R indentation is filled with COMMENTS. No matter how good your code is indented, no matter how many lines you put between the logical blocks, if your code isn't commented, it's fucking harder to understand it.
|
I can't agree. You don't need comments if the code is intelligently written. It has also nothing to do with the style indentation.
A code which is written to be the simplest to read, like if you was reading english, and with each line can be understanding and checked without the need to read the whole code, doesn't need comments.
They are disadvantages like indicating what the user wanted to do but not what does really the code or comments can be wrong or not updated.
In such case, it would be more consistent to write a code which is easy to understand. So like coding intelligently, commenting in the same way would be more appropriate, only when necessary or like commenting at the start of the function to provide what does the function, explaining the params etc..
There are severals things you could do to improve the readability :
- Well named the variables ;
- Replacing expression by variables ;
- Replacing numeric values by constants or enums ;
- Replacing expression groups by functions ;
- Replacing arrays by structures ;
- Well named the function ;
- Avoiding repetition ;
- Saving the result in a var ;
- Well organized each part of the code ;
- Well presented the code ;
- Keeping the same style for the whole code ;
- etc, etc.
Using comments, yes, but it should be used with parsimony and placed intelligently.
__________________