4 ms·
Don’t do this, it makes it a huge pain to test bar(). When you write the initial code to figure out bar, just throw that code in a unit test so you can run it
by notfish 2y ago
Don’t do this, it makes it a huge pain to test bar().
When you write the initial code to figure out bar, just throw that code in a unit test so you can run it any time. Stop throwing tests away!
- heisenzombie 2y agoYes, perhaps I wasn’t clear — I’m advocating for just the inlined version, not the nested function in the general case. The nested function is, I think, fine when it’s so tiny it’s not worth unit testing (like, it-could-have-been-a-lambda small) or when bar is returned by foo (ie foo is higher order), in which case you can test the return value. Apart from that… restraint!