4 ms·
>A data field called "imageURL" that's a string -- is that a remote or local URL? Where did it come from/how much can I trust that it's well-formed? Put that i
by andrepd 6y ago
>A data field called "imageURL" that's a string -- is that a remote or local URL? Where did it come from/how much can I trust that it's well-formed?
Put that information in your types and (i) you don't need to write those comments and (ii) the compiler can help you check if you haven't made mistakes.
- wool_gather 6y agoI said "why isn't this a `URL` instead of a string". I know we should "Put that information in your types". The code is written. I can't safely make that change until I know the invariants, and if the person who wrote the code had written a doc comment, I would know them.
- a1369209993 6y ago> The code is [already] written[ and doesn't include that information in its types]. By that logic, the code is already written and doesn't include that information in its comments, either. > if the person who wrote the code had written a doc comment, I would know [the invariants]. If you're going to ask that the person who wrote the code have written it differently, there's (in general, at least) no reason to ask for comments in preference to types.