2 ms·
Indeed. And if well written, the majority of the code shouldn't need comments. For example, well-chosen descriptive identifier names can make code fairly self-d
by magicalhippo 4y ago
Indeed. And if well written, the majority of the code shouldn't need comments. For example, well-chosen descriptive identifier names can make code fairly self-documenting.
The comments then should then be reserved for the cases where it is not obvious why or how something is done, or for assumptions that can't be expressed through code (type system or similar).
So instead of having the following
// set i equal to five
i = 5;
either skip the comment, or, since 5 might seem arbitrary, comment why 5:
// first four slots are reserved
i = 5;