4 ms·
I have a personal rule: If I need a comment, it goes at the beginning of the function. This neatly groups the comment with the code it applies to. Occasionall
by javert 5y ago
I have a personal rule: If I need a comment, it goes at the beginning of the function.
This neatly groups the comment with the code it applies to.
Occasionally I have to make a function "just" for this grouping purpose, but that's fine.
- mpoteat 5y agoThis is also my practice. Any code that is complicated enough to require a special comment is also complicated enough to be its own function.
- javert 5y agoExactly my thinking. Very well said.
- truetraveller 5y agoThis is a nice rule of thumb. Works great for 90% of use cases. For the other 10%, it's "acceptable". I like it. It also discourages "what" comments, and encourages longer "why" comments. The biggest benefit is: standardization, and no need to think about comments again.