3 ms·
My taste is that function level comments describe the "what" and inline comments describe the "why". So at a function level the comments is giving a highlevel
by pacaro 6y ago
My taste is that function level comments describe the "what" and inline comments describe the "why".
So at a function level the comments is giving a highlevel description to the reader as to the functionality contained, and at the line level comments exist only to say describe the programmers intentionality, why it was implemented this way rather than some other way.
I have generally found (there are always exceptions) that if you find yourself needing "what" comments within a function you should be considering breaking it into smaller pieces.
I've been being paid to write c/c++ for about 25 years
- emerged 6y agoThe main takeaway here might be that two 25 year veterans both make function level and line level comments. The particulars are somewhat of a matter of flavor preference :)
- ghusbands 6y agoThat is not a particularly useful takeaway, especially when one of them is pointing out that particular comments in a function are problematic. The particulars matter.