5 ms·
This type of thing is my response to anyone who says "your code should be clear enough that it doesn't need comments": you can't encode external invariant into
by ranger207 4y ago
This type of thing is my response to anyone who says "your code should be clear enough that it doesn't need comments": you can't encode external invariant into source code
- maleldil 4y agoI think you're missing the point. People who say that are talking about messy code that needs clarification from comments – those cases likely need to be rewritten to be clearer. This is entirely unrelated to _why_ the code does what it does, which the issue here. That definitely needs comments when it's not obvious.
- strager 4y agoIn the OP's case, the _why_ can be encoded in function names. For example: function DatePicker() { function handleDateChange(event) { preventDialogFoobarFromClosing(event); ... } return ( <ThirdPartyDatePicker onChange={handleDateChange} /> ); } function preventDialogFoobarFromClosing(event) { event.preventDefault(); }
- anomaloustho 4y agoI think those people would say to wrap the stopProgation in a function named. doNotTriggerEventInFoobarJS()