| ▲ | frumiousirc 4 days ago | |
The article is about comments. But, more generally, I think the issue here is about naming things. Names capture ideas. Only if we name something can we (or at least I) reason about it. The more clear and descriptive a name for something is, the less cognitive load is required to include the thing in that reasoning. TFA's example that "weight" is a better variable name than "w" is because "weight" immediately has a meaning while use of "w" requires me to carry around the cumbersome "w is weight" whenever I see or think about "w". Function names serve the same purpose as variable names but for operations instead of data. Of course, with naming, context matters and defining functions adds lines of code which adds complexity. As does defining overly verbose variable names: "the_weight_of_the_red_ball" instead of "weight". So, some balance that takes into account the context is needed and perhaps there is some art in finding that balance. Comments, then, provide a useful intermediate on a spectrum between function-heavy "Uncle Bob" style and function-less "stream of consciousness" style. | ||
| ▲ | 8note 2 days ago | parent [-] | |
the first time you write something, descriptive names are handy, but if youre writing a second or thrid copy, or trying to combine several back down into one, those names are all baggage and come with a full mental model. an alternative ive seen work well is names that arent descriptive on their own, but are unique and memorable, and can be looked up from a dictionary | ||