4 ms·
I think there's a place for the "# retrieve data" sort of comment. Suppose you're skimming rather than reading the code, either trying to get a high-level overv
by gjm11 10y ago
I think there's a place for the "# retrieve data" sort of comment. Suppose you're skimming rather than reading the code, either trying to get a high-level overview of what it does or looking for the particular bit of it where a particular thing happens. Then, sure, you could just read all the code; but most of us can skim-read a small quantity of text faster than a larger quantity of code. In a syntax-colouring editor it's easy to ignore everything but the comments, and if the top-level structure of what's happening is sketched in the comments that's helpful.
How helpful depends, of course, on the style of the code; in particular, it gets less helpful as the length of functions/methods goes down, and in the limit of "ravioli code" where everything is decomposed into 3-line methods whose main task is calling other 3-line methods, it doesn't help at all and the sort of comment you need to help with skimming is an overview of how the pieces fit together. At the other extreme, if you have the sort of 1000-line function that's quite common in e.g. numerical code, these structure-sketching comments can be invaluable.