3 ms·
Function names certainly can get out of sync, just as comments can. But my experience is that it's less of a problem. Actually, there is an additional and prob
by javert 12y ago
Function names certainly can get out of sync, just as comments can. But my experience is that it's less of a problem.
Actually, there is an additional and probably much more important reason that I prefer "functions over comments", and that is the functions can be nested.
With comments, I often find myself needing a big comment that describes the next several chunks of things, and each of those chunks has some comments, too. So call those "level 1" and "level 2" comments.
People tend to distinguish these cases like:
/* ***************************
level-one comment
*************************** */
and then
/* level-two comment */
But what if you have something that really "should" be a level-two comment (because it's just one small thing that doesn't have subdivisions), but it comes after a level-one comment? Now you need an end delimeter for level-one comments, like this:
/* *****************
done with that
******************* */
Now at this point, your code is nasty and non-readable and it's not obvious that things have been kept in sync over time. We could just avoid all this ambiguity by using nested functions that are nonetheless only called from one place and thus _could have_ been manually inlined in theory (but, per my practice, are not).