Avoid optional arguments for explicitness?

I’m not sure why a test would fail? Wouldn’t the test-writers be writing their tests on the assumption that the default is … whatever it is in the code?

I understand the idea that explicitness of all parameters has value. But the closer you get to “business logic” the less that’s the case, I’ve found. Sure, for reusable modules where you can imagine multiple use-cases (hence, multiple sensible defaults), it can be the case that the defaults need to be bundled together into a config. Heck, I’ve done it. But the closer you get to the “top of the application”, I’ve found, the more places where there’s only one sensible default.

All that said,

In addition, explicitness is good for reading others’ code or our old code.

this is always, always in tension with the simple fact that verbosity is its own barrier to comprehensibility.

3 Likes