15 ms·
Sometimes 2 lines of code is just better than 6 and not worth the extra brain cycles. There's DRY, then there's premature optimization.
by jedimastert 5y ago
Sometimes 2 lines of code is just better than 6 and not worth the extra brain cycles.
There's DRY, then there's premature optimization.
- karmicthreat 5y agoThis is pretty much the case. It was a quickly needed report of data from our ERP system and dumped into an excel sheet to use. I had not used Pandas before but seemed like a good fit for me t build this out. The people who needed this info were not very sure about what they needed, so being un-DRY is better. This is only a maybe 2 page Jupyter sheet. So it's not a huge deal. In any case, DRY is just an optimization theme. And optimizing for understanding/intent is a higher priority for me. Sometimes they intersect, sometimes not.
- AnonCoward4 5y agoI disagree that this is premature, but best practice. This example is actually a small lesson how this autocomplete can construct slightly less readable code. Of course not really a problem of the tool as you have to refactor anyway.
- josefx 5y ago> Sometimes 2 lines of code is just better than 6 and not worth the extra brain cycles. I am unsure about what could possibly be better about them? Twice the chance to misspell one of the string constants? Twice the time to write the code, which in this case seems to be the big blocker? Twice the code to update in case any of it has to change? Twice the complexity per line of code?