4 ms·
I agree that accurately reading code is important, but no amount of reading just code tell you why something was done. For a contrived example, why does a spec
by sqeaky 10y ago
I agree that accurately reading code is important, but no amount of reading just code tell you why something was done.
For a contrived example, why does a specific function/class use an array instead of a dictionary/hash table? A comment explaining that the dictionary was 500x slower in tests could fix that.
I suspect that is exactly the kind of comments you would want someone to "sit up and read" but I didn't want to assume.
- emodendroket 10y agoYeah, exactly. If I'm putting comments inside a method (as opposed to the docstring kind of stuff) I'm writing something like "it might seem like it would be better to do [xyz], but that's actually not a good idea because of [abc]."
- braveo 10y agoThat's specifically why I said documentation gives the context. Why the API uses a hash table instead of an array is something for the documentation of said API, not code comments.