4 ms·
The issue is if you need A, B, and C to do a task and your function fails if it doesn’t retrieve it, won’t it waste time cleaning ingredients for a dish you can
by exdsq 4y ago
The issue is if you need A, B, and C to do a task and your function fails if it doesn’t retrieve it, won’t it waste time cleaning ingredients for a dish you can’t make? I don’t think it’s less readable than
carrot = fetch carrot
onion = fetch onion
celery = fetch celery
clean(carrot)
clean(onion)
clean(celery)
cook(carrot, onion, celery)
- cehrlich 4y agoThis is absolutely true. But if cleaning your data takes barely any compute and only fails less than 1% of the time, it’s splitting hairs. The way I think about it is, how would I write it if performance didn’t matter? And then from that point I think about what compromises I can make that improve performance at the expense of something else (readability, etc) Disclaimer: I’m not trying to argue that my preference is _better_.
- exdsq 4y agoYeah that's fair! This is one of those times when coding is similar to writing and mostly personal aesthetics.